You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “SQL Server Cast”.
You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “SQL Server Cast”.
Is the word to be used really ‘append’? “you need to append the number comprising the date into a string.” Is it really a ‘padding’ of the number 0?
Looks like it should be right instead of left
Agree! If you use left and it’s i.e day 23 you will get ’02′ with left method.
What about @mydate =’2009-12-11′, output =20090201 ?
Hi, You can find that answer here:
http://sqlserverplanet.com/sql/cast-date-with-no-time/
SELECT CONVERT(varchar(12),GETDATE(), 112) — 20090629
Any date with double digit month and/or day is incorrect with this method (0 + left(x,2) will always start with 0)