From Now() to Current_timestamp in Postgresql
Use an interval instead of an integer:
SELECT *
FROM table
WHERE auth_user.lastactivity > CURRENT_TIMESTAMP - INTERVAL '100 days'
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
Here is an example ...
select * from tablename where to_char(added_time, 'YYYY-MM-DD') = to_char( now(), 'YYYY-MM-DD' )
added_time is a column name which I converted to char for match