Returns the number of months from the beginning of the calendar to the specified date.
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.
An expression that results in a DATE, TIMESTAMP, or TIMESTAMP WITH TIME ZONE value.
The business calendar for the session.
Name of the database where the function is located.
This is a Teradata extension to the ANSI SQL:2011 standard.
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.
The result is an INTEGER value representing the number of months since and including the beginning of the calendar.
The MonthNumber_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.
If the current date is May 5, 1901, the following query returns
17 because May 5, 1901, is in the 17th month since the start of the Teradata calendar
The following query returns
17 because May 5, 1901, is in the 17th month since the start of the COMPATIBLE calendar
SELECT TD_SYSFNLIB.MONTHNUMBER_OF_CALENDAR(DATE '1901-05-05', ’COMPATIBLE’);