首页 > 解决方案 > oracle:使用 sysdate 查找两个日期之间的日期

问题描述

我需要根据当前日期获取日期在日期之间的列表或行;

我想像这样

select * from myTable where calendar_date between trunc(sysdate) and trunc(sysdate-14) 

它什么也不返回,而

select * from myTable where calendar_date = trunc(sysdate) 

select * from myTable where calendar_date = trunc(sysdate-15)

会在那天返回行我错过了什么?

标签: sqloracle

解决方案


select * from myTable where calendar_date between trunc(sysdate) and trunc(sysdate-14)

之间更改顺序。第一个较小的日期 第二个较大的日期

select * from myTable where calendar_date between trunc(sysdate-14) and trunc(sysdate) 

推荐阅读