Convert
Explicitly converts a data type expression to another data type.
Convert (data_type [(length)], expression [, style])
Style Parameter
Date Format style, which converts datetime or smalldatetime data to character data (nchar, nvarchar, Char, varchar, nchar, or nvarchar data type); or string format style, to convert float, real, money, or smallmoney data to character data (nchar, nvarchar, Char, varchar, nchar, or nvarchar data type ).
SQL Server supports the use of Kuwait Algorithm Data format in the Arabic style.
In the table, the two columns on the left represent converting datetime or smalldatetime to the style value of the character data. Add 100 to the style value to obtain the four-digit year (yyyy) of the century ).
Without Century digital (yy) with Century digital (YYYY)
Standard
Input/Output **
-0 or 100 (*) Default Value: Mon dd yyyy hh: miam (or pm)
1 101 us mm/DD/YYYY
2 102 ANSI yy. Mm. dd
3 103 UK/French dd/mm/yy
4 104 German dd. mm. yy
5 105 Italian DD-mm-yy
6 106-dd mon YY
7 107-mon DD, YY
8 108-hh: mm: SS
-9 or 109 (*) Default Value + millisecond mon dd yyyy hh: MI: SS: mmmam (or pm)
10 110 US mm-dd-yy
11 111 YY/MM/DD in Japan
12 112 ISO yymmdd
-13 or 113 (*) European default value + millisecond dd mon yyyy hh: mm: SS: Mmm (24 h)
14 114-hh: MI: SS: Mmm (24 h)
-20 or 120 (*) ODBC specification yyyy-mm-dd hh: mm: ss [. fff]
-21 or 121 (*) ODBC specifications (in milliseconds) yyyy-mm-dd hh: mm: ss [. fff]
-126 (***) iso8601 yyyy-mm-dd thh: mm: SS: Mmm (without spaces)
-130 * Kuwait dd mon yyyy hh: MI: SS: mmmam
-131 * Kuwait dd/mm/yy hh: MI: SS: mmmam
* The default value (Style 0, 100, 9, 109, 13, 113, 20, 120, 21, or 121) always returns century digits (yyyy ).
Therefore, you can directly use convert (varchar (10), '2017-11-18 16:28:00 ', 2005 ).