时间格式的转为2006-02-06
结果为VARHCAR
select convert ( varchar ( 10 ), getdate (), 121 ) -- 结果:2006-02-06
select convert ( varchar ( 7 ), getdate (), 121 ) -- 结果:2006-02
结果为DATATIME
select cast ( convert ( varchar ( 10 ), getdate (), 121 ) as datetime )
select cast ( convert ( varchar ( 7 ), getdate (), 121 ) + ' -01 ' as datetime )
select convert ( varchar ( 10 ), getdate (), 121 ) -- 结果:2006-02-06
select convert ( varchar ( 7 ), getdate (), 121 ) -- 结果:2006-02
结果为DATATIME
select cast ( convert ( varchar ( 10 ), getdate (), 121 ) as datetime )
select cast ( convert ( varchar ( 7 ), getdate (), 121 ) + ' -01 ' as datetime )