From Now() to Current_timestamp in Postgresql

后端 未结 5 1506
既然无缘
既然无缘 2021-01-30 19:31

In mysql I am able to do this:

SELECT *
FROM table
WHERE auth_user.lastactivity > NOW() - 100

now in postgresql I am using this query:

5条回答
  •  耶瑟儿~
    2021-01-30 20:11

    You can also use now() in Postgres. The problem is you can't add/subtract integers from timestamp or timestamptz. You can either do as Mark Byers suggests and subtract an interval, or use the date type which does allow you to add/subtract integers

    SELECT now()::date + 100 AS date1, current_date - 100 AS date2
    

提交回复
热议问题