NOW

Return the current transaction timestamp, identical to CURRENT_TIMESTAMP.

Category: datetimeReturns: TIMESTAMP WITH TIME ZONEDialect: PostgreSql

Syntax

NOW()

Description

## Overview Returns the current date and time (with time zone) as a single TIMESTAMP, captured at the start of the current transaction. NOW is the traditional short name for the same value returned by CURRENT_TIMESTAMP and TRANSACTION_TIMESTAMP. Use NOW in INSERT and UPDATE statements for audit columns, in filters that compute rolling time windows, and in any expression where a transaction-stable 'right now' instant is needed. ## Behavior - Returns a TIMESTAMP WITH TIME ZONE value. - Never returns NULL. - Stable within a transaction: every call inside the same transaction produces the same instant. - Functionally identical to CURRENT_TIMESTAMP() and TRANSACTION_TIMESTAMP(). - Differs from STATEMENT_TIMESTAMP (re-captured per statement) and CLOCK_TIMESTAMP (re-captured per call). - The function-call parentheses are required. ## Timezone handling - Carries the session time zone offset. - Converting to a specific zone: use NOW() AT TIME ZONE 'UTC' or any other valid IANA zone name. - Casting to TIMESTAMP WITHOUT TIME ZONE drops the offset and leaves the wall-clock value in the session zone. ## Compatibility - Long-standing extension to the SQL standard; behaves exactly like CURRENT_TIMESTAMP. Prefer CURRENT_TIMESTAMP when writing portable SQL.

Examples

-- Current transaction timestamp
SELECT NOW();
-- Record the current timestamp in an audit row
INSERT INTO security.audit.access_log (action, created_at)
VALUES ('update', NOW());
-- Age of each open order
SELECT order_id, NOW() - placed_at AS elapsed
FROM commerce.sales.orders
WHERE status = 'open';
-- Confirm equivalence of NOW and CURRENT_TIMESTAMP
SELECT NOW() = CURRENT_TIMESTAMP() AS are_equal;
-- Contrast transaction-stable NOW with advancing CLOCK_TIMESTAMP
SELECT NOW() AS transaction_ts, CLOCK_TIMESTAMP() AS wall_clock_ts;
-- Hourly buckets relative to NOW
SELECT DATE_TRUNC('hour', event_ts) AS hour,
       COUNT(*) AS events
FROM telemetry.web.requests
WHERE event_ts >= NOW() - INTERVAL '24 hours'
GROUP BY hour
ORDER BY hour;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →