Tuesday, April 20, 2010

Format Date or Time without “/”

Format the date or time without dividing characters, as well as concatenate the date and time string:

Sample statement

Output

select replace(convert(varchar, getdate(),111),'/','')

20100413

select replace(convert(varchar, getdate(),101),'/','') + replace(convert(varchar, getdate(),108),':','')

20100413 004426

Select cast(int, convert(char,getdate(),111))

20100413

No comments: