Is the style of the date format used to convert datetime or smalldatetime data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types), or to convert character data of known date or time formats to datetime or smalldatetime data; or the string format used to convert float, real, money, or smallmoney data to character data (nchar, nvarchar, char, varchar, nchar, or nvarchar data types). When style is NULL, the result returned is also NULL.
Note: |
|---|
|
The styles listed in this topic are supported by SQL Server in the described combinations with CONVERT target data types. All other styles and combinations are not supported. Do not use any unsupported styles. Using an unsupported style or an unsupported combination of style and target data type might return an error or unreliable results. These results are not guaranteed across releases of SQL Server.
|
SQL Server supports the date format in Arabic style by using the Kuwaiti algorithm.
In the following table, the two columns on the left represent the style values for converting datetime or smalldatetime data to character data. Add 100 to a style value to obtain a four-place year that includes the century (yyyy).
|
Without century (yy) (1)
|
With century (yyyy)
|
Standard
|
Input/Output (3)
|
|---|
|
-
|
0 or 100 (1, 2)
|
Default
|
mon dd yyyy hh:miAM (or PM)
|
|
1
|
101
|
U.S.
|
mm/dd/yyyy
|
|
2
|
102
|
ANSI
|
yy.mm.dd
|
|
3
|
103
|
British/French
|
dd/mm/yy
|
|
4
|
104
|
German
|
dd.mm.yy
|
|
5
|
105
|
Italian
|
dd-mm-yy
|
|
6
|
106 (1)
|
-
|
dd mon yy
|
|
7
|
107 (1)
|
-
|
Mon dd, yy
|
|
8
|
108
|
-
|
hh:mi:ss
|
|
-
|
9 or 109 (1, 2)
|
Default + milliseconds
|
mon dd yyyy hh:mi:ss:mmmAM (or PM)
|
|
10
|
110
|
USA
|
mm-dd-yy
|
|
11
|
111
|
JAPAN
|
yy/mm/dd
|
|
12
|
112
|
ISO
|
yymmdd
|
|
-
|
13 or 113 (1, 2)
|
Europe default + milliseconds
|
dd mon yyyy hh:mi:ss:mmm(24h)
|
|
14
|
114
|
-
|
hh:mi:ss:mmm(24h)
|
|
-
|
20 or 120 (2)
|
ODBC canonical
|
yyyy-mm-dd hh:mi:ss(24h)
|
|
-
|
21 or 121 (2)
|
ODBC canonical (with milliseconds)
|
yyyy-mm-dd hh:mi:ss.mmm(24h)
|
|
-
|
126 (4)
|
ISO8601
|
yyyy-mm-ddThh:mi:ss.mmm (no spaces)
|
|
|
127(6, 7)
|
ISO8601 with time zone Z.
|
yyyy-mm-ddThh:mi:ss.mmmZ
(no spaces)
|
|
-
|
130 (1, 2)
|
Hijri (5)
|
dd mon yyyy hh:mi:ss:mmmAM
|
|
-
|
131 (2)
|
Hijri (5)
|
dd/mm/yy hh:mi:ss:mmmAM
|
1 These style values return nondeterministic results. Includes all (yy) (without century) styles and a subset of (yyyy) (with century) styles.
2 The default values (style 0 or 100, 9 or 109, 13 or 113, 20 or 120, and 21 or 121) always return the century (yyyy).
3 Input when you convert to datetime; output when you convert to character data.
4 Designed for XML use. For conversion from datetime or smalldatetime to character data, the output format is as described in the previous table.
5 Hijri is a calendar system with several variations. SQL Server 2005 uses the Kuwaiti algorithm.
Important: |
|---|
|
By default, SQL Server interprets two-digit years based on a cutoff year of 2049. That is, the two-digit year 49 is interpreted as 2049 and the two-digit year 50 is interpreted as 1950. Many client applications, such as those based on Automation objects, use a cutoff year of 2030. SQL Server provides the two digit year cutoff configuration option that changes the cutoff year used by SQL Server and allows for the consistent treatment of dates. We recommend specifying four-digit years.
|
6 Only supported when casting from character data to datetime or smalldatetime. When character data that represents only date or only time components is cast to the datetime or smalldatetime data types, the unspecified time component is set to 00:00:00.000, and the unspecified date component is set to 1900-01-01.
7The optional time zone indicator, Z, is used to make it easier to map XML datetime values that have time zone information to SQL Server datetime values that have no time zone. Z is the indicator for time zone UTC-0. Other time zones are indicated with HH:MM offset in the + or - direction. For example: 2006-12-12T23:45:12-08:00.
When you convert to character data from smalldatetime, the styles that include seconds or milliseconds show zeros in these positions. You can truncate unwanted date parts when you convert from datetime or smalldatetime values by using an appropriate char or varchar data type length.
The following table shows the values for style that can be used for converting float or real to character data.
|
Value
|
Output
|
|---|
|
0 (default)
|
A maximum of 6 digits. Use in scientific notation, when appropriate.
|
|
1
|
Always 8 digits. Always use in scientific notation.
|
|
2
|
Always 16 digits. Always use in scientific notation.
|
Note: |
|---|
|
If style 126 is specified for conversion from float and real the output is equivalent to the style value of 2 and 1, respectively.
|
The following table shows the values for style that can be used for converting money or smallmoney to character data.
|
Value
|
Output
|
|---|
|
0 (default)
|
No commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 4235.98.
|
|
1
|
Commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 3,510.92.
|
|
2
|
No commas every three digits to the left of the decimal point, and four digits to the right of the decimal point; for example, 4235.9819.
|
Note: |
|---|
|
If style 126 is specified for conversion from money, or smallmoney to character data, the output is equivalent to the style value of 2.
|
The following table shows the values for style that can be used for converting string input to xml data.
|
Value
|
Output
|
|---|
|
0 (default)
|
Use default parsing behavior that discards insignificant white space and does not allow for an internal DTD subset.
Note: |
When you convert to the xml data type, SQL Server 2005 insignificant white space is handled differently than in XML 1.0. For more information, see Generating XML Instances.
|
|
1
|
Preserve insignificant white space. This style setting sets the default xml:space handling to behave the same as if xml:space="preserve" has been specified instead.
|
|
2
|
Enable limited internal DTD subset processing.
If enabled, the server can use the following information that is provided in an internal DTD subset to perform nonvalidating parse operations.
-
Defaults for attributes are applied.
-
Internal entity references are resolved and expanded.
-
The DTD content model will be checked for syntactical correctness.
The parser will ignore external DTD subsets. It also does not evaluate the XML declaration to see whether the standalone attribute is set yes or no, but instead parses the XML instance as if it is a stand-alone document.
|
|
3
|
Preserve insignificant white space and enable limited internal DTD subset processing.
|