Chris G
Chris G

Reputation: 13

Postgresql query records since 22:00 yesterday

I'm trying to build a postgres query to pull records since 22:00 the previos day. Through the research I've done, I have come up with:

SELECT field1, field2, field3
WHERE field2 >= CONCAT((DATE(now()::timestamp::date - '1 day'::INTERVAL)) || ' 22:00:00')
ORDER BY field2 ASC;

It errors on the >=

When running by itself: select CONCAT(DATE(now()::timestamp::date - '1 day'::INTERVAL) || ' 22:00:00')

it produces the correct string: "2019-02-12 22:00:00"

Upvotes: 1

Views: 70

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269823

One method is:

where field2 >= current_date - interval '2 hour'

Upvotes: 1

Related Questions