sql - 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)
会在那天返回行我错过了什么?
解决方案
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)
推荐阅读
- amazon-web-services - AWS-SES 服务未使用 Boto3 在成功响应时发送批量模板电子邮件
- r - 没有带有警告的拟合曲线:“ggplot2:stat_smooth 警告:`stat_smooth()` 中的计算失败:未找到对象'重量'”
- regex - 正则表达式匹配特定字符串,但只匹配新行上的第一个字符串
- css - .left-column[] 和 .right-column][] 不对齐
- angular - Databinding with A-Frame
- mongodb - Is better to have multiple collections with thousands of documents or one collection with 100 million documents?
- python - VSCode Python package inspection failure
- visual-studio-code - Visual Studio Code 中的 Jupyter 笔记本不使用活动虚拟环境
- php - 使用 facebook webdriver 清除 textarea
- reactjs - 让用户决定一个页面中有多少项