EXTRACT function

The EXTRACT function extracts fields from datetime values and intervals.

The result is INTEGER for YEAR, MONTH, DAY, HOUR, and MINUTE extracts, but FLOAT for SECOND extracts. If the SourceDate is NULL, the result is NULL regardless of the type of extract.

Syntax

EXTRACT extracts individual fields from datetime values and intervals. You can extract a field only if it is present in the datetime value specified in the second parameter. Either a parse-time or a runtime error is generated if the requested field does not exist within the data type.

Example

EXTRACT(YEAR FROM CURRENT_DATE)
and
EXTRACT(HOUR FROM LOCAL_TIMEZONE)
both work without error, but
EXTRACT(DAY FROM CURRENT_TIME)
fails.
Related concepts
ESQL
Related tasks
Developing ESQL
Related reference
Syntax preference
ESQL datetime functions