简体   繁体   English

SQL问题-ODBC连接

[英]SQL Issue - ODBC Connection

At the moment we have a line that pulls the ship date of our orders from the system: 目前,我们有一条线从系统中提取订单的发货日期:

and o.actualshipdate like sysdate

Sysdate is the systematical date of all shipped orders on the current date. Sysdate是当前日期所有发货订单的系统日期。

How can we change it or adjust to make it show the orders shipped on the current systematical date but in a certain time frame: 我们如何更改或调整它以显示在当前系统日期但在特定时间范围内发货的订单:

The query works with the following line but we would have to adjust the date everyday. 该查询适用于以下行,但我们必须每天调整日期。 We would like to have this automated for the current date. 我们希望在当前日期自动执行此操作。

Below line needs to be adjusted: 下面的行需要调整:

and to_char(o.actualshipdate, 'YYYYMMDD HH24:MI') between '20171220 13:00' and '20171220 13:00'

In oracle, we have sysdate to provide the current system date. 在oracle中,我们有sysdate提供当前系统日期。 Check doc for sysdate 检查sysdate文件

If you want a query to get the last 5 hrs shipment details the condition should look like 如果要查询以获取最近5小时的装运详细信息,则情况应如下所示

and shipmentdate >= (sysdate-(5/24))

If you want last 5 mins then 如果您要持续5分钟,那么

and shipmentdate >= (sysdate-(5/1440))

where 1440 = 24*60. 1440 = 24 * 60。

If you want for the last 1 day then 如果您想要过去1天,

and shipmentdate >= sysdate-1

Hope you got the idea.. 希望你有主意..

Please note that all this will work only if the shipmentdate is a date datatype column. 请注意,只有当shippdatedate是日期数据类型列时,所有这些操作才有效。 Otherwise the query will change a little bit. 否则查询将有所改变。


Also you can use between if you want a time-frame for eg. 如果您想要一个时间范围,例如,您也可以在之间使用。

and shipmentdate between (sysdate-(10/24)) and (sysdate-(5/24))

And if your shipmentdate can have future records then for all the above conditions use 如果您的发货日期可以有将来的记录,则可以使用上述所有条件

and shipmentdate between sysdate-x and sysdate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM