Tabel berikut berisi daftar format tanggal yang dapat Anda berikan ke CONVERT()
berfungsi saat Anda mengonversi nilai tanggal/waktu menjadi string.
Format ini disediakan sebagai argumen ketiga opsional saat memanggil CONVERT()
fungsi. Mereka disediakan sebagai ekspresi integer yang menentukan bagaimana CONVERT()
fungsi akan memformat tanggal.
Dalam semua contoh berikut, tanggal input disediakan oleh SYSDATETIME()
fungsinya adalah:
2020-11-08 12:09:47.2360235
Format | Contoh Kode | Keluaran |
---|---|---|
0 | CONVERT(nvarchar, SYSDATETIME(), 0) | 8 November 2020 12:09 |
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) | 11-11-20 |
6 | CONVERT(nvarchar, SYSDATETIME(), 6) | 08 Nov 20 |
7 | CONVERT(nvarchar, SYSDATETIME(), 7) | 08 November, 20 |
8 | CONVERT(nvarchar, SYSDATETIME(), 8) | 12:09:47 |
9 | CONVERT(nvarchar, SYSDATETIME(), 9) | 8 November 2020 12:09:47.360235PM |
10 | CONVERT(nvarchar, SYSDATETIME(), 10) | 08-11-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) | 08-11-2020 12:09:47 |
21 | CONVERT(nvarchar, SYSDATETIME(), 21) | 08-11-2020 12:09:47.2360235 |
22 | CONVERT(nvarchar, SYSDATETIME(), 22) | 08/11/20 12:09:47 WIB |
23 | CONVERT(nvarchar, SYSDATETIME(), 23) | 08-11-2020 |
24 | CONVERT(nvarchar, SYSDATETIME(), 24) | 12:09:47 |
25 | CONVERT(nvarchar, SYSDATETIME(), 25) | 08-11-2020 12:09:47.2360235 |
26 | CONVERT(nvarchar, SYSDATETIME(), 26) | 11-08-2020 12:09:47.2360235 |
27 | CONVERT(nvarchar, SYSDATETIME(), 27) | 08-11-2020 12:09:47.2360235 |
28 | CONVERT(nvarchar, SYSDATETIME(), 28) | 11-2020-08 12:09:47.2360235 |
29 | CONVERT(nvarchar, SYSDATETIME(), 29) | 11-08-2020 12:09:47.2360235 |
30 | CONVERT(nvarchar, SYSDATETIME(), 30) | 11-08-2020 12:09:47.2360235 |
31 | CONVERT(nvarchar, SYSDATETIME(), 31) | -11-08-2020 |
32 | CONVERT(nvarchar, SYSDATETIME(), 32) | 08-11-2020 |
33 | CONVERT(nvarchar, SYSDATETIME(), 33) | 11-2020-08 |
34 | CONVERT(nvarchar, SYSDATETIME(), 34) | 11-08-2020 |
35 | CONVERT(nvarchar, SYSDATETIME(), 35) | 08-2020-11 |
100 | CONVERT(nvarchar, SYSDATETIME(), 100) | 8 November 2020 12:09 |
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) | 11-08-2020 |
106 | CONVERT(nvarchar, SYSDATETIME(), 106) | 08 Nov 2020 |
107 | CONVERT(nvarchar, SYSDATETIME(), 107) | 08 November 2020 |
108 | CONVERT(nvarchar, SYSDATETIME(), 108) | 12:09:47 |
109 | CONVERT(nvarchar, SYSDATETIME(), 109) | 8 November 2020 12:09:47.360235PM |
110 | CONVERT(nvarchar, SYSDATETIME(), 110) | 08-11-2020 |
111 | CONVERT(nvarchar, SYSDATETIME(), 111) | 2020/11/08 |
112 | CONVERT(nvarchar, SYSDATETIME(), 112) | 201108 |
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) | 08-11-2020 12:09:47 |
121 | CONVERT(nvarchar, SYSDATETIME(), 121) | 08-11-2020 12:09:47.2360235 |
126 | CONVERT(nvarchar, SYSDATETIME(), 126) | 08-11-2020T12:09:47.2360235 |
127 | CONVERT(nvarchar, SYSDATETIME(), 127) | 08-11-2020T12: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 |
Untuk pemformatan tanggal sadar-lokal, gunakan FORMAT()
fungsi.