PostgreSQL 18 reference · 13 entries

PostgreSQL Date and Time Functions

PostgreSQL date and time functions: now(), date_trunc(), EXTRACT, age(), to_char(), to_date(), make_interval(), date_bin(), AT TIME ZONE and generate_series().

Use date for days, timestamptz for moments in time (stored in UTC, shown in the session time zone) and interval for durations. Dates support arithmetic: order_date + 7, or now() - interval '1 month'.

NameDescriptionSince
NOW() Return the current date and time with time zone, fixed at the start of the transaction. current_timestamp is the same.
CURRENT_DATE Return today's date (in the session's time zone) as a date with no time part. It's written without parentheses.
DATE_TRUNC() Truncate a timestamp or interval to a unit such as 'month', 'week' or 'hour', for grouping by period.
EXTRACT() Get one field from a date, time or interval, such as the year, month, day of week or epoch seconds.
AGE() Subtract dates and return a 'symbolic' interval in years, months and days. With one argument it counts from today.
TO_CHAR() Format a date, timestamp or number as text with a pattern such as 'DD Mon YYYY' or 'FM999,990.00'.
TO_DATE() Parse text into a date using a format pattern, such as to_date('09/03/2026', 'DD/MM/YYYY').
TO_TIMESTAMP() Convert Unix epoch seconds to a timestamp with time zone, or parse text into one with a format pattern.
MAKE_DATE() Build a date from year, month and day numbers. make_timestamp() and make_time() do the same for other types. 9.4
MAKE_INTERVAL() Build an interval from named parts, such as make_interval(days => 10, hours => 2). 9.4
DATE_BIN() Round a timestamp down into fixed-size buckets, such as 15-minute slots, counted from an origin. 14
AT TIME ZONE Convert between time zones: timestamptz AT TIME ZONE 'Asia/Tokyo' shows local time there.
GENERATE_SERIES() Generate a set of rows from a start to a stop value with a step: numbers, or timestamps with an interval step.

Was this page helpful?