now

Returns the current query timestamp.

Syntax

now()

Arguments

None.

Returns

Returns timestamp. The value is fixed for the query and represents an instant in UTC, with nanosecond precision.

Examples

Select events from the last 15 minutes:

VALUES
    (now() - 'PT2m'::interval, 'payment_failed'),
    (now() - 'PT8m'::interval, 'checkout_started'),
    (now() - 'PT20m'::interval, 'cart_viewed')
SELECT $0 AS event_time, $1 AS event
WHERE event_time >= now() - 'PT15m'::interval
SELECT event, now() - event_time AS age
ORDER BY age
+------------------+------+
| event            | age  |
+------------------+------+
| payment_failed   | 2m0s |
| checkout_started | 8m0s |
+------------------+------+

Every now() in this statement uses the same query instant, so the cutoff and calculated ages are consistent.