请问用SQL查询时间时怎么去掉查询结果中的“时分秒”,只要精确到“天”。
我写的查询语句是:selectdistinctorderdateas"672"fromd_orderdetailinnerjoinD_OrderonD_Order.ord...
我写的查询语句是:
select distinct orderdate as "672"
from d_orderdetail inner join D_Order on D_Order.orderid=d_orderdetail.orderid
where (productid=672)
and (orderdate between '2004-07-01' and '2005-06-30')
order by orderdate
查询的结果如上图所示,现在想要将查询的结果显示为“yyyy-mm-dd”,请问语句该怎么写? 展开
select distinct orderdate as "672"
from d_orderdetail inner join D_Order on D_Order.orderid=d_orderdetail.orderid
where (productid=672)
and (orderdate between '2004-07-01' and '2005-06-30')
order by orderdate
查询的结果如上图所示,现在想要将查询的结果显示为“yyyy-mm-dd”,请问语句该怎么写? 展开
展开全部
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
这样就可以了
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
这样就可以了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select distinct to_char(orderdate,'yyyy-mm-dd') as "672"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Select CONVERT(varchar(30),getdate(),102) 这个可以转换
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
STR_TO_DATE((DATE_FORMAT(time,'%Y-%m-%d')),'%Y-%m-%d')
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询