The following table contains a list of the date formats that you can provide to the CONVERT()
function when you convert a date/time value to a string.
These formats are provided as an optional third argument when calling the CONVERT()
function. They’re provided as an integer expression that specifies how the CONVERT()
function will format the date.
In all of the following examples, the input date provided by the SYSDATETIME()
function was:
2020-11-08 12:09:47.2360235
Format | Example Code | Output |
---|---|---|
0 | CONVERT(nvarchar, SYSDATETIME(), 0) | Nov 8 2020 12:09PM |
1 | CONVERT(nvarchar, SYSDATETIME(), 1) | 11/08/20 |
2 | CONVERT(nvarchar, SYSDATETIME(), 2) | 20.11.08 |
3 | CONVERT(nvarchar, SYSDATETIME(), 3) | 08/11/20 |
4 | CONVERT(nvarchar, SYSDATETIME(), 4) | 08.11.20 |
5 | CONVERT(nvarchar, SYSDATETIME(), 5) | 08-11-20 |
6 | CONVERT(nvarchar, SYSDATETIME(), 6) | 08 Nov 20 |
7 | CONVERT(nvarchar, SYSDATETIME(), 7) | Nov 08, 20 |
8 | CONVERT(nvarchar, SYSDATETIME(), 8) | 12:09:47 |
9 | CONVERT(nvarchar, SYSDATETIME(), 9) | Nov 8 2020 12:09:47.2360235PM |
10 | CONVERT(nvarchar, SYSDATETIME(), 10) | 11-08-20 |
11 | CONVERT(nvarchar, SYSDATETIME(), 11) | 20/11/08 |
12 | CONVERT(nvarchar, SYSDATETIME(), 12) | 201108 |
13 | CONVERT(nvarchar, SYSDATETIME(), 13) | 08 Nov 2020 12:09:47.2360235 |
14 | CONVERT(nvarchar, SYSDATETIME(), 14) | 12:09:47.2360235 |
20 | CONVERT(nvarchar, SYSDATETIME(), 20) | 2020-11-08 12:09:47 |
21 | CONVERT(nvarchar, SYSDATETIME(), 21) | 2020-11-08 12:09:47.2360235 |
22 | CONVERT(nvarchar, SYSDATETIME(), 22) | 11/08/20 12:09:47 PM |
23 | CONVERT(nvarchar, SYSDATETIME(), 23) | 2020-11-08 |
24 | CONVERT(nvarchar, SYSDATETIME(), 24) | 12:09:47 |
25 | CONVERT(nvarchar, SYSDATETIME(), 25) | 2020-11-08 12:09:47.2360235 |
26 | CONVERT(nvarchar, SYSDATETIME(), 26) | 2020-08-11 12:09:47.2360235 |
27 | CONVERT(nvarchar, SYSDATETIME(), 27) | 11-08-2020 12:09:47.2360235 |
28 | CONVERT(nvarchar, SYSDATETIME(), 28) | 11-2020-08 12:09:47.2360235 |
29 | CONVERT(nvarchar, SYSDATETIME(), 29) | 08-11-2020 12:09:47.2360235 |
30 | CONVERT(nvarchar, SYSDATETIME(), 30) | 08-2020-11 12:09:47.2360235 |
31 | CONVERT(nvarchar, SYSDATETIME(), 31) | 2020-08-11 |
32 | CONVERT(nvarchar, SYSDATETIME(), 32) | 11-08-2020 |
33 | CONVERT(nvarchar, SYSDATETIME(), 33) | 11-2020-08 |
34 | CONVERT(nvarchar, SYSDATETIME(), 34) | 08-11-2020 |
35 | CONVERT(nvarchar, SYSDATETIME(), 35) | 08-2020-11 |
100 | CONVERT(nvarchar, SYSDATETIME(), 100) | Nov 8 2020 12:09PM |
101 | CONVERT(nvarchar, SYSDATETIME(), 101) | 11/08/2020 |
102 | CONVERT(nvarchar, SYSDATETIME(), 102) | 2020.11.08 |
103 | CONVERT(nvarchar, SYSDATETIME(), 103) | 08/11/2020 |
104 | CONVERT(nvarchar, SYSDATETIME(), 104) | 08.11.2020 |
105 | CONVERT(nvarchar, SYSDATETIME(), 105) | 08-11-2020 |
106 | CONVERT(nvarchar, SYSDATETIME(), 106) | 08 Nov 2020 |
107 | CONVERT(nvarchar, SYSDATETIME(), 107) | Nov 08, 2020 |
108 | CONVERT(nvarchar, SYSDATETIME(), 108) | 12:09:47 |
109 | CONVERT(nvarchar, SYSDATETIME(), 109) | Nov 8 2020 12:09:47.2360235PM |
110 | CONVERT(nvarchar, SYSDATETIME(), 110) | 11-08-2020 |
111 | CONVERT(nvarchar, SYSDATETIME(), 111) | 2020/11/08 |
112 | CONVERT(nvarchar, SYSDATETIME(), 112) | 20201108 |
113 | CONVERT(nvarchar, SYSDATETIME(), 113) | 08 Nov 2020 12:09:47.2360235 |
114 | CONVERT(nvarchar, SYSDATETIME(), 114) | 12:09:47.2360235 |
120 | CONVERT(nvarchar, SYSDATETIME(), 120) | 2020-11-08 12:09:47 |
121 | CONVERT(nvarchar, SYSDATETIME(), 121) | 2020-11-08 12:09:47.2360235 |
126 | CONVERT(nvarchar, SYSDATETIME(), 126) | 2020-11-08T12:09:47.2360235 |
127 | CONVERT(nvarchar, SYSDATETIME(), 127) | 2020-11-08T12:09:47.2360235 |
130 | CONVERT(nvarchar, SYSDATETIME(), 130) | 23 ربيع الاول 1442 12:09:47.23 |
131 | CONVERT(nvarchar, SYSDATETIME(), 131) | 23/03/1442 12:09:47.2360235PM |
For locale-aware date formatting, use the FORMAT()
function.