显示两个日期和日期之间的记录

显示两个日期和日期之间的记录

本文介绍了显示两个日期和日期之间的记录时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个表客户端(client_id,client_name,client_lname)

和订单(Order_Id,Client_Id,Total_Amount,Order_Date,Order_Time,Order_Status)。我必须显示两个日期和时间之间的记录。

我写了这个查询:



 选择 o.Order_Id,c.client_name,c.client_lname,o.Total_Amount,o.Order_Date,o.Order_Time  from  orders  as  o  join  client  as  c  on  o.Client_id = c.Client_id 其中(o.Order_Date   '  01/01/2013'  '  22/01/2013'(o。 Order_Time 之间的code-keyword> '  17:41:59'  '  20:42:04' o.Order_Status = '  1' 订单  o.Order_Id 





它运作正常..但我不会在以下情况下工作ex.I想要查找从01/01/2013 23:12:00到22/01/2013 08:05:10的记录。如果条件是像01/01/2013 16:10:04到22/01/2013 16:20:04。帮帮我。谢谢

解决方案



I have 2 tables client (client_id,client_name,client_lname)
and orders(Order_Id,Client_Id,Total_Amount,Order_Date,Order_Time,Order_Status).I have to display records between two dates and time.
I have wrote this query :

select o.Order_Id,c.client_name,c.client_lname,o.Total_Amount,o.Order_Date,o.Order_Time from orders as o join client as c on o.Client_id=c.Client_id where (o.Order_Date between '01/01/2013' and '22/01/2013' ) and (o.Order_Time between '17:41:59' and '20:42:04') and o.Order_Status='1' order by o.Order_Id 



It works fine..but I wont work in the following case for ex.I want to find records from 01/01/2013 23:12:00 to 22/01/2013 08:05:10 . and if the condition is like 01/01/2013 16:10:04 to 22/01/2013 16:20:04.Help me out .Thanks

解决方案



这篇关于显示两个日期和日期之间的记录时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 14:25