【问题标题】:How to make query in postgresql which will find all records which are started more than 6 hours?如何在 postgresql 中进行查询,以查找所有启动时间超过 6 小时的记录?
【发布时间】:2014-01-30 19:41:50
【问题描述】:

如何在postgresql中查询所有6小时前开始的记录?

在我的表中,我有一列存储上次使用的 utc 时间,以毫秒为单位(长整数)。

SELECT *
FROM exams
WHERE started < HERE_I_NEED_UTC_IN_MILLISECONDS - 6 * 60 * 1000 * 1000;

【问题讨论】:

    标签: postgresql postgresql-9.1 postgresql-9.2


    【解决方案1】:
    select *
    from exams
    where started < extract(epoch from (current_timestamp - interval '6' hour))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-26
      • 2010-11-02
      • 2019-05-08
      • 2020-09-07
      • 2020-08-30
      • 1970-01-01
      相关资源
      最近更新 更多