EXTRACT function

Start of changeThe EXTRACT function extracts fields (or calculates values) from datetime values and intervals.End of change

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 overview
Related tasks
Developing ESQL
Related reference
Syntax diagrams: available types
ESQL datetime functions