Sql中將datetime轉換成字符串的辦法(CONVERT)。本站提示廣大學習愛好者:(Sql中將datetime轉換成字符串的辦法(CONVERT))文章只能為提供參考,不一定能成為您想要的結果。以下是Sql中將datetime轉換成字符串的辦法(CONVERT)正文
表中‘*'表現的寄義解釋: * 默許值(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 應用個中的科威特算法。
4、不帶世紀數位的實例代碼(正文的表現非有用的款式號):
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
5、帶世紀數位的實例代碼(正文的表現非有用的款式號):
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