我正在尝试从两个日期之间获取订单,这些订单的时间介于5PM和6:20 PM之间。
SELECT CREATION_DATE_TIME_STAMP
FROM SHIPMENT_HEADER
WHERE CREATION_DATE_TIME_STAMP between '2019-08-01 17:00:00:000' and '2019-10-31 18:20:000' AND
ORDER_TYPE = 'Catalog'
答案 0 :(得分:2)
您需要有关日期和时间部分的单独条件。日期和时间函数众所周知是特定于数据库的,但是类似这样:
SELECT CREATION_DATE_TIME_STAMP
FROM SHIPMENT_HEADER
WHERE CREATION_DATE_TIME_STAMP >= '2019-08-01' AND
CREATION_DATE_TIME_STAMP < '2019-11-01' AND
CAST(CREATION_DATE_TIME_STAMP as TIME) >= '17:00:00' AND
CAST(CREATION_DATE_TIME_STAMP as TIME) <= '18:20:00' AND
ORDER_TYPE = 'Catalog';
这假设一个简单的cast()
就足以提取时间。