在oracle中获取当前日期之前日期的所有记录
Get All records of previous date from current date in oracle
我想要 table 的所有数据,这些数据在我的 table 中可用超过 6 个月。所以为此我写了下面的查询,但它没有给出确切的记录。
Select * from changerequests where lastmodifiedon < sysdate - 180;
问题是我正在获取 2020 年 4 月 2 日 的记录,这不超过 6 个月。请提出查询
如果您想要最近 6 个月内最后一次修改的记录,那么您需要相反的不等式条件:
where lastmodifiedon > sysdate - 180
请注意,180 天不等于 6 个月。您可能想使用 add_months()
来获得更准确的内容:
where lastmodifiedon > add_months(sysdate, -12)
我想要 table 的所有数据,这些数据在我的 table 中可用超过 6 个月。所以为此我写了下面的查询,但它没有给出确切的记录。
Select * from changerequests where lastmodifiedon < sysdate - 180;
问题是我正在获取 2020 年 4 月 2 日 的记录,这不超过 6 个月。请提出查询
如果您想要最近 6 个月内最后一次修改的记录,那么您需要相反的不等式条件:
where lastmodifiedon > sysdate - 180
请注意,180 天不等于 6 个月。您可能想使用 add_months()
来获得更准确的内容:
where lastmodifiedon > add_months(sysdate, -12)