DECLARE @STR VARCHAR(50)
---This is with seconds
SET @STR='ID'+(SELECT REPLACE(CONVERT(VARCHAR,GETDATE(),5),'-','')+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':',''))
---This is with milliseconds
PRINT @STR
SET @STR='ID'+(SELECT REPLACE(CONVERT(VARCHAR,GETDATE(),5),'-','')
+(REPLACE(CONVERT(VARCHAR,GETDATE(),114),':','')))
PRINT @STR
Output:
1)ID131014102125
2)ID131014102145910
---This is with seconds
SET @STR='ID'+(SELECT REPLACE(CONVERT(VARCHAR,GETDATE(),5),'-','')+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':',''))
---This is with milliseconds
PRINT @STR
SET @STR='ID'+(SELECT REPLACE(CONVERT(VARCHAR,GETDATE(),5),'-','')
+(REPLACE(CONVERT(VARCHAR,GETDATE(),114),':','')))
PRINT @STR
Output:
1)ID131014102125
2)ID131014102145910
Formatted Invoice No.
Select 'EI-U5/'+Cast(right(Year(DateAdd(YY,-1,getdate())),2) as varchar)+'-'+Cast(right(Year(getdate()),2) as varchar)+'/'+REPLACE(CONVERT(VARCHAR,GETDATE(),114),':','')
Output:
EI-U5/14-15/113021013