Tuesday, 31 March 2009

Date Conversions in SQL

Does what it says on the tin. I find this a particularly handy trick to know when trying to copy & paste SQL data from Query Analyser into Excel, because the default date/time format causes Excel to scramble the dates into nonsense.

Stupid Excel.

Anyway, on with the show.

CONVERT(CHAR(19),GETDATE()) -- gives 31 March 2003 11:19
CONVERT(CHAR(11),GETDATE(),106) -- gives 31 March 2003

No comments:

Post a Comment