question

Mohan avatar image
Mohan asked

Different date formats into one standardize format(mm/dd/yyyy)

The following formats need to be converted in MM/DD/YYYY format in sql server 25-May-13 27/06/2013 Mon 06/17/2013 Mon 20/05/2013 4-Jul-13 7/6/2013 6/19/2013 5-Jul Jul-5
t-sql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
eaglescout avatar image
eaglescout answered
Use the "CONVERT(data_type(length),expression,style)" code to convert dates into different formats. The code can be modified to reflect your specifications. see this link for further exp. of CONVERT() code: http://www.w3schools.com/sql/func_convert.asp
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

+1. Although, in general, I strongly suggest everyone do formatting on the front-end and let SQL Server just store dates & datetimes in whatever you define as the default format. Those functions can seriously get in the way when people start using them on strings to compare to functions, etc.
3 Likes 3 ·
I agree with you Grant, properly assigning data types to columns in the front end, can save a whole lots of time in the future.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.