人气不行,换个地方看看--一case语句问题
declare @t table(dt varchar(30))
insert @t
select '2006-02-28 13:00:00.000 ' union all
select '2005-03-32 13:00:00.000 ' union all
select '2004-02-30 13:00:00.000 ' union all
select '2003-17-36 13:70:00.000 ' union all
select '2004-06-31 13:60:00.000 ' union all
select '2000-02-28 13:00:77.000 ' union all
select '2002-03-30 '
SELECT case
when convert(int,substring(dt,6,2))=2 and (convert(int,substring(dt,9,2))=28 or convert(int,substring(dt,9,2))=29 ) and ((convert(int,substring(dt,1,4))%100+convert(int,substring(dt,1,4))%4)> =1 or convert(int,substring(dt,1,4))%400=0)
then stuff(dt,9,2, '28 ')
when (convert(int,substring(dt,6,2))=7 or convert(int,substring(dt,6,2))=8 or
convert(int,substring(dt,6,2))=10 or convert(int,substring(dt,6,2))=11 or
convert(int,substring(dt,6,2))=1 or convert(int,substring(dt,6,2))=3 or
convert(int,substring(dt,6,2))=5 )
and convert(int,substring(dt,9,2))> 31
then stuff(dt,9,2, '31 ')
&