SQL时间类型转换(国外英文资料).doc
文本预览下载声明
SQL时间类型转换(国外英文资料)
The convert of usage:
Convert (the converted data type, variable/constant/field name, [transformation control parameter])
The use of the cast:
Cast (variable/constant/field name, converted data type)
The use of the convert
Select count (*) from T_Client where convert (varchar (10), OrderTime, 120) = convert (varchar (10), getdate (), 120)
The use of the cast:
Cast (variable/constant/field name, converted data type)
Select cast (getdate () as varchar (10))
CAST and CONVERT
The expression of a data type is explicitly converted to another type of data. CAST and CONVERT provide similar functionality.
grammar
Use CAST:
CAST AS data_type
Use CONVERT:
CONVERT (data_type [(length)], expression [, style])
parameter
expression
Any effective Microsoft? SQL Server # 8482; Expression. See the expressions for more information.
data_type
The data types provided by the target system, including bigint and sql_variant. You cannot use user-defined data types. For more information about available data types, see the data types.
length
Nchar, nvarchar, char, varchar, binary or varbinary data type optional parameters.
style
Date format style, so as to convert a datetime or smalldatetime data to character data (nchar, nvarchar, char, varchar, nchar or nvarchar data types). Or string format style, which will float, real, money or smallmoney data into the character data (nchar, nvarchar, char, varchar, nchar or nvarchar data types).
SQL Server supports the data format in the Arabic style of the Kuwaiti algorithm.
In the table, the two columns on the left represent the style values that convert datetime or smalldatetime to character data. Add 100 to the style and get the four years of the century (yyyy).
So you dont have a century place.
standard
Input/output * *
-0 or 100 (*) default values mon dd yyy: miAM (or PM)
1 101 U.S. mm/dd/yyy
2, 102, ANSI y.mm
3, 103 British/French dd/mm/yy
4 104 German dd. Mm. Yy
5105 Italian dd - mm - yy
6106 - dd mon yy
7, 107 - mon dd, yy
10
显示全部