项目中时间普遍都是通过日期筛选,但是数据库中存储的日期是Date类型,精确到秒。
当查询条件如下时,因为处理的粗心,就会查询出错
查询条件 select * from table where date between sysdate and sysdate;
实际查询的时间是2020年8月5日14:01:50 - 2020年8月5日14:01:57
而不是8月5日当天的时间
对时间坐下简单处理,把查询范围设置成 2020-8-5 00:00:00 - 2020-8-6 00:00:00
select * from table where date between to_date(to_char(sysdate,'yyyy-MM-dd'),'yyyy-MM-dd hh24:mi:ss') and to_date(to_char(sysdate+1,'yyyy-MM-dd'),'yyyy-MM-dd hh24:mi:ss')