YEAR
Syntax
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> YEAR[YEAR]:::quoted
YEAR --> End((END))
Purpose
The YEAR SQL function extracts the year from a date/time.
See also DAY, HOUR, MICROSECOND, MILLISECOND, MINUTE, MONTH, and SECOND.
Parameters:
- Input (
datetime): the date/time to extract the years from.
Returns: the year as an int32.
Examples
The following example extracts the years from current system date/time in UTC:
select year(sysdateutc)
-------------------
2026
The following example extracts the years from January 1, 2026:
select year(to_date('20260101', 'YYYYMMDD'))
-------------------
2026