Oracle数据库中查看特定时间段的写法

xiaoxiao2021-02-28  24

select sysdate from dual 当前时间是 2018/6/6 4:04:06 create table test_aa (c1 date); insert into test_aa values (to_date('2018-06-05 19:55:44' ,'yyyy-mm-dd hh24:mi:ss')); insert into test_aa values (to_date('2018-06-05 03:55:44' ,'yyyy-mm-dd hh24:mi:ss')); insert into test_aa values (to_date('2018-06-06 13:55:44' ,'yyyy-mm-dd hh24:mi:ss')); commit; select * from test_aa where (c1 >= trunc(sysdate - 1) + 18 / 24 and c1 < trunc(sysdate)) or (c1 >= trunc(sysdate - 1) and c1 < trunc(sysdate - 1) + 6 / 24);

这是查看昨天18点到24点之间和昨天凌晨零点到早晨6点之间记录的sql语法。

转载请注明原文地址: https://www.6miu.com/read-2631864.html

最新回复(0)