select convert(varchar(10),GetDate(),101) as [MM/DD/YYYY]
The inline select explanation:
Arg 1: The datatype you are converting the data type too
Arg 2: Item being selected which is going to be a datetime object. Sample uses the GetDate function to make the sample generic.
Arg 3: The data format you need
MM/DD/YY | USA | SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY] | 11/23/98 |
MM/DD/YYYY | USA | SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY] | 11/23/1998 |
DD.MM.YY | German | SELECT CONVERT(VARCHAR(8), GETDATE(), 4) AS [DD.MM.YY] | 25.12.05 |
DD.MM.YYYY | German | SELECT CONVERT(VARCHAR(10), GETDATE(), 104) AS [DD.MM.YYYY] | 25.12.2005 |
Thanks to the team at sql server helper. They have the complete list of Date formats
http://www.sql-server-helper.com/tips/date-formats.aspx
No comments:
Post a Comment