select sysdate from dual
当前时间是 2018/6/6 4:04:06
原文链接:https://www.f2er.com/oracle/205892.html当前时间是 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语法。