YEAROFWEEK
functionsupportedCore SQL functionsExtracts the corresponding date part from a date or timestamp. These functions are alternatives to using the DATE_PART (or EXTRACT) function with the equivalent date part (see Supported date and time parts).
Syntax
YEAR( <date_interval_or_timestamp_expr> )
YEAROFWEEK( <date_or_timestamp_expr> )
YEAROFWEEKISO( <date_or_timestamp_expr> )
DAY( <date_interval_or_timestamp_expr> )
DAYOFMONTH( <date_or_timestamp_expr> )
DAYOFWEEK( <date_or_timestamp_expr> )
DAYOFWEEKISO( <date_or_timestamp_expr> )
DAYOFYEAR( <date_or_timestamp_expr> )
WEEK( <date_or_timestamp_expr> )
WEEKOFYEAR( <date_or_timestamp_expr> )
WEEKISO( <date_or_timestamp_expr> )
MONTH( <date_interval_or_timestamp_expr> )
QUARTER( <date_or_timestamp_expr> )
Parameters
| Name | Required | Description |
|---|---|---|
date_or_timestamp_expr | required | A date or a timestamp, or an expression that can be evaluated to a date or a timestamp. |
date_interval_or_timestamp_expr | required | A date, an interval, or a timestamp, or an expression that can be evaluated to a date, an interval, or a timestamp. When an interval value is passed to the function, the YEAR and MONTH functions support a year-month interval, or an expression that can be evaluated to a year-month interval. The DAY function supports a day-time interval, or an expression that can be evaluated to a day-time interval. |
Returns
This function returns a value of type NUMBER.
Usage notes
- Function name | Date part extracted from input date or timestamp | Possible values
- YEAR | Year | Any valid year (for example, 2025)
- YEAROFWEEK [1] | Year that the extracted week belongs to | Any valid year (for example, 2025)
- YEAROFWEEKISO | Year that the extracted week belongs to using ISO semantics | Any valid year (for example, 2025)
- DAY , DAYOFMONTH | Day (number) of the month | 1 to 31
- DAYOFWEEK [1] | Day (number) of the week dictated by session parameters | 0 to 7
- DAYOFWEEKISO | Day (number) of the week using ISO semantics | 1 to 7
- DAYOFYEAR | Day (number) of the year | 1 to 366
- WEEK , WEEKOFYEAR [1] | Week (number) of the year | 1 to 54
- WEEKISO | Week (number) of the year using ISO semantics | 1 to 53
- MONTH | Month (number) of the year | 1 to 12
- QUARTER | Quarter (number) of the year | 1 to 4
- [1] Results dictated by the values set for the WEEK_OF_YEAR_POLICY and/or WEEK_START session parameters.