日期:2014-05-18  浏览次数:20348 次

从数据库取时间的格式设置(2007-10-11 14:00:00 .577)
在数据库中有一列,数据类型是datetime 
select conDate from Table 
得到 2007-10-11 14:00:00.577
怎么把取出的结果直接得出:2007-10-11
把后面的时间去掉,只要日期

------解决方案--------------------
select convert(varchar(10),conDate,120) conDate from table
------解决方案--------------------
select convert(varchar(10),getdate(),120) currentdate 

/*
currentdate 
----------- 
2007-10-11

(所影响的行数为 1 行)
*/
------解决方案--------------------
老乌龟速度真快。。。
呵呵

select convert(varchar(10),conDate,120) conDate from table
or:
select convert(varchar(10),conDate,20) conDate from table