Skip to main content
Retrieves the time unit, such as year or hour, from a DATE, TIMESTAMP, or TIMESTAMPTZ value.

Syntax

Parameters

TIMESTAMPTZ values are converted to local time according to the session’s time_zone setting before extracting the time_unit. The set of allowed time_unit values depends on the data type of <expression>. Furthermore, the return type depends on the time_unit.

Time Units

Return Types

Depending on the requested time unit, either an integer or a decimal.

Remarks

The EXTRACT function can be used in the PARTITION BY clause of CREATE TABLE commands.
The following example extracts the year, month, and day from a date literal:

Rows: 1Execution time: 9.10ms