15.00 - DayNumber_Of_Month - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)

DayNumber_Of_Month

Purpose  

Returns the number of days from the beginning of the month to 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:

  • DATE
  • TIMESTAMP
  • TIMESTAMP WITH TIME ZONE
  • The second argument, calendar_name, is optional and is defined with the following argument data types:

  • VARCHAR
  • NULL
  • 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 from 1 through 31.

    Usage Notes

    The DayNumber_Of_Month 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 s

    In both of the following examples, no business calendar is set for the session, so the query uses the system-defined business calendar Teradata.

    The following query gives the day number of the month as 31 instead of 1 because the input is converted to UTC 2009-12-31 19:00:00.

    SET TIME ZONE INTERVAL ‘05:00’ HOUR TO MINUTE;
    SELECT DAYNUMBER_OF_MONTH (TIMESTAMP‘2010-01-01 00:00:00’);

    The following query gives the day number of the month as 31 instead of 1 because the input is converted to UTC 2009-12-31 21:00:00.

    SEL DAYNUMBER_OF_MONTH (TIMESTAMP’2010-01-01 00:00:00+03:00’);