Date Format | T-SQL Code | Output |
Mon DD YYYY HH:MIAM (or PM) |
SELECT CONVERT(VARCHAR(20), GETDATE(), 100) | Feb 23 2014 3:00PM |
MM/DD/YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY] | 02/23/14 |
MM/DD/YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY] | 02/23/2014 |
YY.MM.DD | SELECT CONVERT(VARCHAR(8), GETDATE(), 2) AS [YY.MM.DD] | 14.02.23 |
YYYY.MM.DD | SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD] | 2014.02.23 |
DD/MM/YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 3) AS [DD/MM/YY] | 23/02/14 |
DD/MM/YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY] | 23/02/2014 |
DD.MM.YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 4) AS [DD.MM.YY] | 23.02.14 |
DD.MM.YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 104) AS [DD.MM.YYYY] | 23.02.2014 |
DD-MM-YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 5) AS [DD-MM-YY] | 23-02-14 |
DD-MM-YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 105) AS [DD-MM-YYYY] | 23-02-2014 |
DD Mon YY | SELECT CONVERT(VARCHAR(9), GETDATE(), 6) AS [DD MON YY] | 23 Feb 14 |
DD Mon YYYY | SELECT CONVERT(VARCHAR(11), GETDATE(), 106) AS [DD MON YYYY] | 23 Feb 2014 |
Mon DD, YY | SELECT CONVERT(VARCHAR(10), GETDATE(), 7) AS [Mon DD, YY] | Feb 23, 14 |
Mon DD, YYYY | SELECT CONVERT(VARCHAR(12), GETDATE(), 107) AS [Mon DD, YYYY] | Feb 23, 2014 |
HH:MM:SS | SELECT CONVERT(VARCHAR(8), GETDATE(), 108) | 05:15:10 |
Mon DD YYYY HH:MI:SS:MMMAM (or PM) | SELECT CONVERT(VARCHAR(26), GETDATE(), 109) | Feb 23 2014 10:15:10:214AM |
MM-DD-YY | SELECT CONVERT(VARCHAR(8), GETDATE(), 10) AS [MM-DD-YY] | 02-23-14 |
MM-DD-YYYY | SELECT CONVERT(VARCHAR(10), GETDATE(), 110) AS [MM-DD-YYYY] | 02-23-2014 |
YY/MM/DD | SELECT CONVERT(VARCHAR(8), GETDATE(), 11) AS [YY/MM/DD] | 14/02/23 |
YYYY/MM/DD | SELECT CONVERT(VARCHAR(10), GETDATE(), 111) AS [YYYY/MM/DD] | 2014/02/23 |
YYMMDD | SELECT CONVERT(VARCHAR(6), GETDATE(), 12) AS [YYMMDD] | 140223 |
YYYYMMDD | SELECT CONVERT(VARCHAR(8), GETDATE(), 112) AS [YYYYMMDD] | 20140223 |
DD Mon YYYY HH:MM:SS:MMM(24h) | SELECT CONVERT(VARCHAR(24), GETDATE(), 113) | 23 Feb 2014 11:30:25:100 |
HH:MI:SS:MMM(24H) | SELECT CONVERT(VARCHAR(12), GETDATE(), 114) AS [HH:MI:SS:MMM(24H)] | 10:15:20:211 |
YYYY-MM-DD HH:MI:SS(24h) | SELECT CONVERT(VARCHAR(19), GETDATE(), 120) | 2014-02-23 16:00:10 |
YYYY-MM-DD HH:MI:SS.MMM(24h) | SELECT CONVERT(VARCHAR(23), GETDATE(), 121) | 2014-02-23 08:15:25.120 |
YYYY-MM-DDTHH:MM:SS:MMM | SELECT CONVERT(VARCHAR(23), GETDATE(), 126) | 2014-02-23T10:25:30:120 |
DD Mon YYYY HH:MI:SS:MMMAM | SELECT CONVERT(VARCHAR(26), GETDATE(), 130) | 23 Feb 2014 10:25:30:120AM |
DD/MM/YYYY HH:MI:SS:MMMAM | SELECT CONVERT(VARCHAR(25), GETDATE(), 131) | 23/02/2014 10:25:30:120AM |
This is a blog where you are going to find tips or solution that are going to be helpful in the technology environment.
Thursday, June 26, 2014
SQL Date Format Examples
Labels:
T-SQL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment