------解决方案-------------------- select substring(日期列,1,4)+'-'+substring(日期列,5,2)+'-'+substring(日期列,7,2) ------解决方案-------------------- select substring(日期列,1,4)+'-'+substring(日期列,5,2)+'-'+substring(日期列,7,2)
from tb
where isdate(日期列)=1--代表是日期类型或者可以转换成日期类型
insert into tb
select '2013-08-08 14:15:12','2013-10-22','20130101'
select convert(varchar(10),CAST(t1 as datetime),120),
convert(varchar(10),CAST(t2 as datetime),120),
convert(varchar(10),CAST(t3 as datetime),120)
from tb
/*
(无列名) (无列名) (无列名)
2013-08-08 2013-10-22 2013-01-01
*/
------解决方案--------------------
select convert(varchar(10),CAST('20130101' as datetime),120)
SELECT
CONVERT(VARCHAR(50),CAST(a AS DATETIME),112) a,
CONVERT(VARCHAR(50),CAST(b AS DATETIME),112) b,
CONVERT(VARCHAR(50),CAST(c AS DATETIME),112) c
FROM @a
-------------------------------
a b c
20130808 20131022 20130101