时间:2021-07-01 10:21:17 帮助过:12人阅读
带世纪数位的实例代码(注释的表示非有效的样式号):
1 SELECT CONVERT(varchar(100), GETDATE(), 100) AS Style100 2 SELECT CONVERT(varchar(100), GETDATE(), 101) AS Style101 3 SELECT CONVERT(varchar(100), GETDATE(), 102) AS Style102 4 SELECT CONVERT(varchar(100), GETDATE(), 103) AS Style103 5 SELECT CONVERT(varchar(100), GETDATE(), 104) AS Style104 6 SELECT CONVERT(varchar(100), GETDATE(), 105) AS Style105 7 SELECT CONVERT(varchar(100), GETDATE(), 106) AS Style106 8 SELECT CONVERT(varchar(100), GETDATE(), 107) AS Style107 9 SELECT CONVERT(varchar(100), GETDATE(), 108) AS Style108 10 SELECT CONVERT(varchar(100), GETDATE(), 109) AS Style109 11 SELECT CONVERT(varchar(100), GETDATE(), 110) AS Style110 12 SELECT CONVERT(varchar(100), GETDATE(), 111) AS Style111 13 SELECT CONVERT(varchar(100), GETDATE(), 112) AS Style112 14 SELECT CONVERT(varchar(100), GETDATE(), 113) AS Style113 15 SELECT CONVERT(varchar(100), GETDATE(), 114) AS Style114 16 --SELECT CONVERT(varchar(100), GETDATE(), 115) AS Style115 17 --SELECT CONVERT(varchar(100), GETDATE(), 116) AS Style116 18 --SELECT CONVERT(varchar(100), GETDATE(), 117) AS Style117 19 --SELECT CONVERT(varchar(100), GETDATE(), 118) AS Style118 20 --SELECT CONVERT(varchar(100), GETDATE(), 119) AS Style119 21 SELECT CONVERT(varchar(100), GETDATE(), 120) AS Style121 22 SELECT CONVERT(varchar(100), GETDATE(), 121) AS Style121 23 --SELECT CONVERT(varchar(100), GETDATE(), 122) AS Style122 24 --SELECT CONVERT(varchar(100), GETDATE(), 123) AS Style123 25 --SELECT CONVERT(varchar(100), GETDATE(), 124) AS Style124 26 --SELECT CONVERT(varchar(100), GETDATE(), 125) AS Style125 27 SELECT CONVERT(varchar(100), GETDATE(), 126) AS Style126 28 SELECT CONVERT(varchar(100), GETDATE(), 127) AS Style127 29 --SELECT CONVERT(varchar(100), GETDATE(), 128) AS Style128 30 --SELECT CONVERT(varchar(100), GETDATE(), 129) AS Style129 31 SELECT CONVERT(varchar(100), GETDATE(), 130) AS Style130 32 SELECT CONVERT(varchar(100), GETDATE(), 131) AS Style131View Code
sql 中字符串截取函数: SUBSTRING(name,start,end)
name: 字符串格式的 字段名
start: 规定开始位置(起始值是 1)
end:截取字符串结束的位置
sql 中Datetime格式转换为字符串格式: 2000-01-01 01:01:01(Datetime) CONVERT(CHAR(19), CURRENT_TIMESTAMP, 120)
CURRENT_TIMESTAMP: 当前时间(此处可以写Datetime格式的字段名,例如ss_updatetime)
其余的参数(CHAR(19), 120等)不用修改
使用之后 2000-01-01 01:01:01(Datetime)变为 2000-01-01 01:01:01(字符串格式)
参考:http://www.jb51.net/article/49174.htm
Sql中将datetime转换成字符串的方法(CONVERT())
标签:height sql sub 1.5 技术分享 express end logs substring