艾丽游戏ing

sql日期格式化 sql日期格式化为月份

艾丽游戏ing 1

今天小爱来给大家分享一些关于sql日期格式化为月份方面的知识吧,希望大家会喜欢哦

1、如果是 SQL Server执行一下如下的 SQL 语句, 就会清楚了SELECT 0 AS ID , Convert(VARCHAR(30), GETDATE(), 0 ) AS result UNION ALLSELECT 100 AS ID , Convert(VARCHAR(30), GETDATE(), 100) AS result UNION ALLSELECT 1 AS ID , Convert(VARCHAR(30), GETDATE(), 1 ) AS result UNION ALLSELECT 101 AS ID , Convert(VARCHAR(30), GETDATE(), 101) AS result UNION ALLSELECT 2 AS ID , Convert(VARCHAR(30), GETDATE(), 2 ) AS result UNION ALLSELECT 102 AS ID , Convert(VARCHAR(30), GETDATE(), 102) AS result UNION ALLSELECT 2 AS ID , Convert(VARCHAR(30), GETDATE(), 2 ) AS result UNION ALLSELECT 102 AS ID , Convert(VARCHAR(30), GETDATE(), 102) AS result UNION ALLSELECT 3 AS ID , Convert(VARCHAR(30), GETDATE(), 3 ) AS result UNION ALLSELECT 103 AS ID , Convert(VARCHAR(30), GETDATE(), 103) AS result UNION ALLSELECT 4 AS ID , Convert(VARCHAR(30), GETDATE(), 4 ) AS result UNION ALLSELECT 104 AS ID , Convert(VARCHAR(30), GETDATE(), 104) AS result UNION ALLSELECT 5 AS ID , Convert(VARCHAR(30), GETDATE(), 5 ) AS result UNION ALLSELECT 105 AS ID , Convert(VARCHAR(30), GETDATE(), 105) AS result UNION ALLSELECT 6 AS ID , Convert(VARCHAR(30), GETDATE(), 6 ) AS result UNION ALLSELECT 106 AS ID , Convert(VARCHAR(30), GETDATE(), 106) AS result UNION ALLSELECT 7 AS ID , Convert(VARCHAR(30), GETDATE(), 7 ) AS result UNION ALLSELECT 107 AS ID , Convert(VARCHAR(30), GETDATE(), 107) AS result UNION ALLSELECT 8 AS ID , Convert(VARCHAR(30), GETDATE(), 8 ) AS result UNION ALLSELECT 108 AS ID , Convert(VARCHAR(30), GETDATE(), 108) AS result UNION ALLSELECT 9 AS ID , Convert(VARCHAR(30), GETDATE(), 9 ) AS result UNION ALLSELECT 109 AS ID , Convert(VARCHAR(30), GETDATE(), 109) AS result UNION ALLSELECT 10 AS ID , Convert(VARCHAR(30), GETDATE(), 10 ) AS result UNION ALLSELECT 110 AS ID , Convert(VARCHAR(30), GETDATE(), 110) AS result UNION ALLSELECT 11 AS ID , Convert(VARCHAR(30), GETDATE(), 11 ) AS result UNION ALLSELECT 111 AS ID , Convert(VARCHAR(30), GETDATE(), 111) AS result UNION ALLSELECT 12 AS ID , Convert(VARCHAR(30), GETDATE(), 12 ) AS result UNION ALLSELECT 112 AS ID , Convert(VARCHAR(30), GETDATE(), 112) AS result UNION ALLSELECT 13 AS ID , Convert(VARCHAR(30), GETDATE(), 13 ) AS result UNION ALLSELECT 113 AS ID , Convert(VARCHAR(30), GETDATE(), 113) AS result UNION ALLSELECT 14 AS ID , Convert(VARCHAR(30), GETDATE(), 14 ) AS result UNION ALLSELECT 114 AS ID , Convert(VARCHAR(30), GETDATE(), 114) AS result UNION ALLSELECT 20 AS ID , Convert(VARCHAR(30), GETDATE(), 20 ) AS result UNION ALLSELECT 120 AS ID , Convert(VARCHAR(30), GETDATE(), 120) AS result UNION ALLSELECT 21 AS ID , Convert(VARCHAR(30), GETDATE(), 21 ) AS result UNION ALLSELECT 121 AS ID , Convert(VARCHAR(30), GETDATE(), 121) AS result带世纪数位 (yy) 带世纪数位 (yyyy)标准输入/输出**- 0 或 100 (*) 默认值 mon dd yyyy hh:miAM(或 PM)1 101 美国 mm/dd/yyyy2 102 ANSI yy.mm.dd3 103 英国/法国 dd/mm/yy4 104 德国 dd.mm.yy5 105 意大利 dd-mm-yy6 106 - dd mon yy7 107 - mon dd, yy8 108 - hh:mm:ss- 9 或 109 (*) 默认值 + 毫秒 mon dd yyyy hh:mi:ss:mmmAM(或 PM)10 110 美国 mm-dd-yy11 111 日本 yy/mm/dd12 112 ISO yymmdd- 13 或 113 (*) 欧洲默认值 + 毫秒 dd mon yyyy hh:mm:ss:mmm(24h)14 114 - hh:mi:ss:mmm(24h)- 20 或 120 (*) ODBC 规范 yyyy-mm-dd hh:mm:ss[.fff]- 21 或 121 (*) ODBC 规范(带毫秒) yyyy-mm-dd hh:mm:ss[.fff]- 126(***) ISO8601 yyyy-mm-dd Thh:mm:ss:mmm(不含空格)- 130* 科威特 dd mon yyyy hh:mi:ss:mmmAM- 131* 科威特 dd/mm/yy hh:mi:ss:mmmAM如:Convert(datetime,120)。

本文到这结束,希望上面文章对大家有所帮助。