分类: Mysql/postgreSQL
2009-05-05 08:37:39
SQL中CONVERT转化函数的用法
CONVERT的使用方法:
格式:
CONVERT(data_type,expression[,style])
说明:
此样式一般在时间类型(datetime,smalldatetime)与字符串类型(nchar,nvarchar,char,varchar)
相互转换的时候才用到.
例子:
Select
结果为
now
---------------------------------------
09/15/2001
/////////////////////////////////////////////////////////////////////////
style数字在转换时间时的含义如下
-------------------------------------------------------------------------------------------------
Style(2位表示年份)
-------------------------------------------------------------------------------------------------
-
-------------------------------------------------------------------------------------------------
1
-------------------------------------------------------------------------------------------------
2
-------------------------------------------------------------------------------------------------
3
-------------------------------------------------------------------------------------------------
4
-------------------------------------------------------------------------------------------------
5
-------------------------------------------------------------------------------------------------
6
-------------------------------------------------------------------------------------------------
7
-------------------------------------------------------------------------------------------------
8
-------------------------------------------------------------------------------------------------
-
-------------------------------------------------------------------------------------------------
10
-------------------------------------------------------------------------------------------------
11
-------------------------------------------------------------------------------------------------
12
-------------------------------------------------------------------------------------------------
-
-------------------------------------------------------------------------------------------------
14
-------------------------------------------------------------------------------------------------
-
-------------------------------------------------------------------------------------------------
-