Skip to content
Advertisement

From Now() to Current_timestamp in Postgresql

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:

SELECT *
FROM table
WHERE auth_user.lastactivity > CURRENT_TIMESTAMP - 100

but I get this error:

operator does not exist: timestamp with time zone - integer

How can I resolve ?

Advertisement

Answer

Use an interval instead of an integer:

SELECT *
FROM table
WHERE auth_user.lastactivity > CURRENT_TIMESTAMP - INTERVAL '100 days'
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement