YEAR
- YEAR(date)[source]
Extracts the year component from a date or array of dates.
The YEAR function returns the year (e.g., 2024) from the provided date. It supports both single dates and arrays of dates, returning an integer or an integer array accordingly.
- Parameters:
date (
Operand) –The date or array of dates from which to extract the year.
Supported types:
DATE
DATETIME
DATE_ARRAY
DATETIME_ARRAY
- Return type:
- Returns:
The year as an integer or array of integers.
Supported types:
INTEGER
INTEGER_ARRAY
- Raises:
ValueError – If the input is not a date or datetime type.
Examples
YEAR(DATE(2025, 9, 3)) # Returns 2025