(编辑:jimmy 日期: 2024/12/23 浏览:2)
表中‘*'表示的含义说明: * 默认值(style 0 或 100、9 或 109、13 或 113、20 或 120、21 或 121)始终返回世纪数位 (yyyy)。
** 当转换为 datetime时输入;当转换为字符数据时输出。
*** 专门用于 XML。对于从 datetime或 smalldatetime 到 character 数据的转换,输出格式如表中所示。对于从 float、money 或 smallmoney 到 character 数据的转换,输出等同于 style 2。对于从 real 到 character 数据的转换,输出等同于 style 1。
**** Hijri 是具有几种变化形式的日历系统,Microsoft? SQL Server? 2000 使用其中的科威特算法。
四、不带世纪数位的实例代码(注释的表示非有效的样式号):
复制代码 代码如下:
SELECT CONVERT(varchar(100), GETDATE(), 0) AS Style0
SELECT CONVERT(varchar(100), GETDATE(), 1) AS Style1
SELECT CONVERT(varchar(100), GETDATE(), 2) AS Style2
SELECT CONVERT(varchar(100), GETDATE(), 3) AS Style3
SELECT CONVERT(varchar(100), GETDATE(), 4) AS Style4
SELECT CONVERT(varchar(100), GETDATE(), 5) AS Style5
SELECT CONVERT(varchar(100), GETDATE(), 6) AS Style6
SELECT CONVERT(varchar(100), GETDATE(), 7) AS Style7
SELECT CONVERT(varchar(100), GETDATE(), 8) AS Style8
SELECT CONVERT(varchar(100), GETDATE(), 9) AS Style9
SELECT CONVERT(varchar(100), GETDATE(), 10) AS Style10
SELECT CONVERT(varchar(100), GETDATE(), 11) AS Style11
SELECT CONVERT(varchar(100), GETDATE(), 12) AS Style12
SELECT CONVERT(varchar(100), GETDATE(), 13) AS Style13
SELECT CONVERT(varchar(100), GETDATE(), 14) AS Style14
--SELECT CONVERT(varchar(100), GETDATE(), 15) AS Style15
--SELECT CONVERT(varchar(100), GETDATE(), 16) AS Style16
--SELECT CONVERT(varchar(100), GETDATE(), 17) AS Style17
--SELECT CONVERT(varchar(100), GETDATE(), 18) AS Style18
--SELECT CONVERT(varchar(100), GETDATE(), 19) AS Style19
SELECT CONVERT(varchar(100), GETDATE(), 20) AS Style21
SELECT CONVERT(varchar(100), GETDATE(), 21) AS Style21
SELECT CONVERT(varchar(100), GETDATE(), 22) AS Style22
SELECT CONVERT(varchar(100), GETDATE(), 23) AS Style23
SELECT CONVERT(varchar(100), GETDATE(), 24) AS Style24
SELECT CONVERT(varchar(100), GETDATE(), 25) AS Style25
--SELECT CONVERT(varchar(100), GETDATE(), 26) AS Style26
--SELECT CONVERT(varchar(100), GETDATE(), 27) AS Style27
--SELECT CONVERT(varchar(100), GETDATE(), 28) AS Style28
--SELECT CONVERT(varchar(100), GETDATE(), 29) AS Style29
--SELECT CONVERT(varchar(100), GETDATE(), 30) AS Style30
--SELECT CONVERT(varchar(100), GETDATE(), 31) AS Style31
五、带世纪数位的实例代码(注释的表示非有效的样式号):
复制代码 代码如下:
SELECT CONVERT(varchar(100), GETDATE(), 100) AS Style100
SELECT CONVERT(varchar(100), GETDATE(), 101) AS Style101
SELECT CONVERT(varchar(100), GETDATE(), 102) AS Style102
SELECT CONVERT(varchar(100), GETDATE(), 103) AS Style103
SELECT CONVERT(varchar(100), GETDATE(), 104) AS Style104
SELECT CONVERT(varchar(100), GETDATE(), 105) AS Style105
SELECT CONVERT(varchar(100), GETDATE(), 106) AS Style106
SELECT CONVERT(varchar(100), GETDATE(), 107) AS Style107
SELECT CONVERT(varchar(100), GETDATE(), 108) AS Style108
SELECT CONVERT(varchar(100), GETDATE(), 109) AS Style109
SELECT CONVERT(varchar(100), GETDATE(), 110) AS Style110
SELECT CONVERT(varchar(100), GETDATE(), 111) AS Style111
SELECT CONVERT(varchar(100), GETDATE(), 112) AS Style112
SELECT CONVERT(varchar(100), GETDATE(), 113) AS Style113
SELECT CONVERT(varchar(100), GETDATE(), 114) AS Style114
--SELECT CONVERT(varchar(100), GETDATE(), 115) AS Style115
--SELECT CONVERT(varchar(100), GETDATE(), 116) AS Style116
--SELECT CONVERT(varchar(100), GETDATE(), 117) AS Style117
--SELECT CONVERT(varchar(100), GETDATE(), 118) AS Style118
--SELECT CONVERT(varchar(100), GETDATE(), 119) AS Style119
SELECT CONVERT(varchar(100), GETDATE(), 120) AS Style121
SELECT CONVERT(varchar(100), GETDATE(), 121) AS Style121
--SELECT CONVERT(varchar(100), GETDATE(), 122) AS Style122
--SELECT CONVERT(varchar(100), GETDATE(), 123) AS Style123
--SELECT CONVERT(varchar(100), GETDATE(), 124) AS Style124
--SELECT CONVERT(varchar(100), GETDATE(), 125) AS Style125
SELECT CONVERT(varchar(100), GETDATE(), 126) AS Style126
SELECT CONVERT(varchar(100), GETDATE(), 127) AS Style127
--SELECT CONVERT(varchar(100), GETDATE(), 128) AS Style128
--SELECT CONVERT(varchar(100), GETDATE(), 129) AS Style129
SELECT CONVERT(varchar(100), GETDATE(), 130) AS Style130
SELECT CONVERT(varchar(100), GETDATE(), 131) AS Style131