请问用SQL查询时间时怎么去掉查询结果中的“时分秒”,只要精确到“天”。

2024-11-03 04:17:01
推荐回答(5个)
回答1:

select distinct Convert(varchar(10),orderdate,120) as "672"
from d_orderdetail inner join D_Order on D_Order.orderid=d_orderdetail.orderid
where (productid=672)
and (Convert(varchar(10),orderdate,120) between '2004-07-01' and '2005-06-30')
order by orderdate

这样就可以了

回答2:

select distinct to_char(orderdate,'yyyy-mm-dd') as "672"

回答3:

Select CONVERT(varchar(30),getdate(),102) 这个可以转换

回答4:

STR_TO_DATE((DATE_FORMAT(time,'%Y-%m-%d')),'%Y-%m-%d')

回答5:

select distinct DATE_FORMAT(orderdate ,'%Y-%m-%d') as "672"

from d_orderdetail inner join D_Order on D_Order.orderid=d_orderdetail.orderid
where (productid=672)
and (DATE_FORMAT(orderdate ,'%Y-%m-%d') between '2004-07-01' and '2005-06-30')
order by orderdate