extract ( field from timestamp ) → numericGet timestamp subfield; see Section 9.9.1
extract(hour from timestamp '2001-02-16 20:38:40') → 20
Get timestamp subfield; see Section 9.9.1
extract ( field from timestamp ) → numericGet timestamp subfield; see Section 9.9.1
extract(hour from timestamp '2001-02-16 20:38:40') → 20
extract ( field from interval ) → numericGet interval subfield; see Section 9.9.1
extract(month from interval '2 years 3 months') → 3
EXTRACT(field FROM source)The
extract function retrieves subfields such as year or hour from date/time values. source must be a value expression of type timestamp, date, time, or interval. (Timestamps and times can be with or without time zone.) field is an identifier or string that selects what field to extract from the source value. Not all fields are valid for every input data type; for example, fields smaller than a day cannot be extracted from a date, while fields of a day or more cannot be extracted from a time. The extract function returns values of type numeric.Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source