Return the current date and time, fixed at transaction start.
CURRENT_TIMESTAMP()
## Overview Returns the current date and time (with time zone) as a single TIMESTAMP value. The result is fixed at the start of the current transaction, so every reference to CURRENT_TIMESTAMP inside a single transaction returns the identical instant. This transaction-stable behavior is important for consistency: row-level audit columns populated with CURRENT_TIMESTAMP in a multi-statement transaction will all carry the same instant, making it easy to reason about when a logical unit of work happened. ## Behavior - Returns a TIMESTAMP WITH TIME ZONE value. - Never returns NULL. - Stable within a transaction: repeated calls return the same instant. - Equivalent to NOW() and TRANSACTION_TIMESTAMP(); all three spellings are interchangeable. - Differs from STATEMENT_TIMESTAMP (new value per statement) and CLOCK_TIMESTAMP (advances during a single statement). - The parentheses are optional; CURRENT_TIMESTAMP and CURRENT_TIMESTAMP() are both accepted. ## Timezone handling - Carries the session time zone offset. Casting to TIMESTAMP WITHOUT TIME ZONE drops the offset and reinterprets the wall-clock value in the session zone. - Use AT TIME ZONE to convert the returned instant to a specific zone, for example CURRENT_TIMESTAMP() AT TIME ZONE 'UTC'. ## Compatibility - Defined in the SQL standard (ANSI/ISO SQL:2016). Both the bare keyword and the function-call forms are widely supported.
-- Current transaction timestamp with time zone
SELECT CURRENT_TIMESTAMP();
-- Record the current timestamp when inserting an audit row
INSERT INTO security.audit.access_log (event_type, created_at)
VALUES ('login', CURRENT_TIMESTAMP());
-- Elapsed interval since each order was placed
SELECT order_id, AGE(CURRENT_TIMESTAMP(), placed_at) AS elapsed
FROM commerce.sales.orders;
-- Demonstrate stability: both columns return the same instant
SELECT CURRENT_TIMESTAMP() AS a, CURRENT_TIMESTAMP() AS b;
-- Compare transaction-stable vs. wall-clock readings
SELECT CURRENT_TIMESTAMP() AS txn_ts, CLOCK_TIMESTAMP() AS wall_ts;
-- Bucket events by the current 5-minute window
SELECT DATE_BIN(INTERVAL '5 minutes', event_ts, CURRENT_TIMESTAMP()) AS bin,
COUNT(*) AS hits
FROM telemetry.web.requests
GROUP BY bin;