Thursday, 28 October 2010

SQL: Format Dates

Formatting dates in T-SQL is generally a nuisance as no format date function exists. In the past I have seen many developers (including myself) use the DATEPART() functions to split the dates and then manually build up a date string.



Alternatively I have seen developers CAST() the date to format.



Recently however, I discovered the different date formats that come standard in SQL Server as part of the CONVERT() function.


For an excellent thorough list of date formats please visit  http://www.sql-server-helper.com/tips/date-formats.aspx

0 comments:

Post a Comment

 

Popular Posts

developer-express Copyright © 2009 Black Nero Blogspot Templatesis Designed by Ipietoon Sponsored by Online Business Journal