records from yesterday in postrgesql
WHERE workorder.createdtime > current_date - 1 -- Yesterday and today
WHERE workorder.createdtime > current_timestamp - interval '1 day' -- last 24hr
> TIMESTAMP 'yesterday'
For convenience, Postgres includes a few hard-coded values as special Date/Time inputs. They include:
yesterday
today
tomorrow
now
Try SELECT TIMESTAMP 'now'
.
For example, here is a query.
SELECT when_row_created_
FROM customer_
WHERE when_row_created_ > TIMESTAMP 'yesterday'
ORDER BY when_row_created_ DESC
;
These commands may not be appropriate to production code, but they certainly are handy in development. Read the docs and do some practice to be sure you understand the behavior of these commands, how the session’s time zone affects them and so on.
Downsides include (a) implicitly ignoring the crucial issue of time zone, and (b) not standard SQL.
where workorder.createdtime >= now() - interval '24 hour'