YearNumber_Of_Calendar
Purpose
Returns the year of the specified date.
Syntax
Syntax Elements
calendar_name
A calendar name. The possible values are Teradata, ISO, and COMPATIBLE.
This argument must be a character literal and cannot be a table column or expression. If you do not name a calendar, Teradata uses the calendar for the session.
expression
An expression that results in a DATE, TIMESTAMP, or TIMESTAMP WITH TIME ZONE value.
NULL
The business calendar for the session.
TD_SYSFNLIB
Name of the database where the function is located.
ANSI Compliance
This is a Teradata extension to the ANSI SQL:2011 standard.
Argument Types
The first argument, expression, is defined with the following data types:
The second argument, calendar_name, is optional and is defined with the following argument data types:
If the argument passed to the function does not match one of these declared data types, an error is returned indicating that the function does not exist.
Result
The result is an INTEGER value representing the year in 4-digit format.
Usage Notes
The YearNumber_Of_Calendar function provides improved performance compared to using the Sys_Calendar.Calendar system view to obtain similar results.
For more information about the CALENDAR system view, see Data Dictionary.
Example
If the current date is June 14, 1906, the following queries return 1906
:
SELECT TD_SYSFNLIB.YEARNUMBER_OF_CALENDAR(CURRENT_DATE);
SELECT TD_SYSFNLIB.YEARNUMBER_OF_CALENDAR (DATE '1906-06-14', ’COMPATIBLE’);