Postgres here; I have a Users table that has the following fields:
create table Users (
id bigserial primary key,
isAdmin boolean not null default false,
beginDate timestamp with time zone not null,
updated timestamp with time zone
);
I want to write a query that fetches any Users records that:
- Have a
beginDatevalue within the last 24 hours (inclusively); AND - Have an
updatedvalue that is older (exclusively) than 24 hours
My best attempt thus far is:
select *
from
Users
where
beginDate >= NOW() - INTERVAL 1 DAY and
updated < NOW() - INTERVAL 1 DAY
But this gives em the following error:
ERROR: syntax error at or near "1"
Position: 59
beginDate >= NOW() - INTERVAL 1 DAY and
^
1 statement failed.
Execution time: 0.03s
Any ideas on what the fix is?
INTERVAL '1' DAY