Timestamp Difference In Hours for PostgreSQL

前端 未结 7 957
执念已碎
执念已碎 2020-12-01 08:46

Is there a TIMESTAMPDIFF() equivalent for PostgreSQL?

I know I can subtract two timestamps to get a postgresql INTERVAL. I just want the

7条回答
  •  一向
    一向 (楼主)
    2020-12-01 09:39

    Get fields where a timestamp is greater than date in postgresql:

    SELECT * from yourtable 
    WHERE your_timestamp_field > to_date('05 Dec 2000', 'DD Mon YYYY');
    

    Subtract minutes from timestamp in postgresql:

    SELECT * from yourtable 
    WHERE your_timestamp_field > current_timestamp - interval '5 minutes'
    

    Subtract hours from timestamp in postgresql:

    SELECT * from yourtable 
    WHERE your_timestamp_field > current_timestamp - interval '5 hours'
    

提交回复
热议问题