34,576
社区成员
发帖
与我相关
我的任务
分享
select convert(datetime, '19'+substring(sidcard,7,6)) from table
where len(sidcard)
select * from from table
where len(sidcard)!=datalength(sidcard) --试下,结果贴出来看看?
[Quote=引用 9 楼 zwfgdlc 的回复:]select convert(datetime,('19'+substring(sidcard,7,2)+'-'+substring(sidcard,9,2)+'-'+substring(sidcard,11,2))) from table
where len(sidcard)=15
少打了个“)”,更正下[Quote=引用 5 楼 geniuswjt 的回复:]
select convert(datetime, '19'+substring('4416248309211351',7,6))
/*
-----------------------
1983-09-21 00:00:00.000
(1 行受影响)
select convert(datetime,('19'+substring(sidcard,7,2)+'-'+substring(sidcard,9,2)+'-'+substring(sidcard,11,2)) from table
where len(sidcard)=15
select convert(datetime, '19'+substring(sidcard,7,6)) from table
where len(sidcard)=15
select '19'+substring(sidcard,7,6) from tb
select convert(datetime, '19'+substring('4416248309211351',7,6))
-----------------------
1983-09-21 00:00:00.000
(1 行受影响)
select convert(datetime, '19'+substring('4416248309211351',7,6))
-----------------------
消息 242,级别 16,状态 3,第 1 行
从 varchar 数据类型到 datetime 数据类型的转换产生一个超出范围的值。
select convert(datetime, '19'+substring('4416248402291351',7,6))
select convert(datetime, '19'+substring('4416248303321351',7,6))
select convert(datetime, '19'+substring('4416248302291351',7,6))