【问题标题】:Where results displayed are less than current time显示的结果小于当前时间
【发布时间】:2017-12-14 14:55:02
【问题描述】:

在 Oracle SQL Developer 上,我希望编写一个 where 函数来提供最近 7 天的数据。我可以自己写那部分,但我需要添加到最后的额外部分是我只想要我当前时间之前过去 7 天的结果。

例如,如果我在今天 14:00 进行查询,我希望它返回过去 7 天的结果,数据只到 14:00,而不是全天。

这可能吗?

【问题讨论】:

    标签: oracle timestamp oracle-sqldeveloper where


    【解决方案1】:

    SYSDATE 是 Oracle 内置的日期函数,它提供精确到 1 秒的当前日期/时间。您所要做的就是:

    select * 
      from whatever
     where whatever.datecol between sysdate - 7 and  sysdate;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-10
      • 2012-04-15
      • 2020-10-11
      • 2018-12-04
      • 2012-11-28
      • 2020-06-21
      • 1970-01-01
      • 2014-01-15
      相关资源
      最近更新 更多