Oracle查询某段日期内某个时间段的数据
查询最近一周12:30分到13:00这段时间内的订单量:
SELECT *
FROM T_ORDER O
WHERE O.CREATEDATETIME BETWEEN
SYSDATE-7 AND
SYSDATE
AND TO_CHAR(O.CREATEDATETIME, 'hh24:mi:ss') BETWEEN '12:30:00' AND
'13:00:00'
SELECT *
FROM T_ORDER O
WHERE O.CREATEDATETIME BETWEEN
SYSDATE-7 AND
SYSDATE
AND TO_CHAR(O.CREATEDATETIME, 'hh24:mi:ss') BETWEEN '12:30:00' AND
'13:00:00'
查询某段日期内某个时间段的订单量:
SELECT *
FROM T_ORDER O
WHERE O.CREATEDATETIME BETWEEN
TO_DATE('2016-10-08 12:30', 'yyyy-mm-dd hh24:mi') AND
TO_DATE('2016-10-14 13:00', 'yyyy-mm-dd hh24:mi')
AND TO_CHAR(O.CREATEDATETIME, 'hh24:mi:ss') BETWEEN '12:30:00' AND
'13:00:00'
FROM T_ORDER O
WHERE O.CREATEDATETIME BETWEEN
TO_DATE('2016-10-08 12:30', 'yyyy-mm-dd hh24:mi') AND
TO_DATE('2016-10-14 13:00', 'yyyy-mm-dd hh24:mi')
AND TO_CHAR(O.CREATEDATETIME, 'hh24:mi:ss') BETWEEN '12:30:00' AND
'13:00:00'