15.00 - td_day_of_week - 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)
Last Update
2018-09-24

td_day_of_week

Purpose  

Returns the day of the week on which the specified date falls.

Syntax  

where:

 

Syntax element…

Specifies…

SYSLIB

the name of the database where the function is located.

expression

an expression that results in a DATE, TIMESTAMP, or TIMESTAMP WITH TIME ZONE value.

Argument Types

td_day_of_week is an overloaded scalar function. It is defined with the following parameter data types:

  • DATE
  • TIMESTAMP
  • TIMESTAMP WITH TIME ZONE
  • 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.

    For more information on overloaded functions, see “Function Name Overloading” in SQL External Routine Programming.

    Result

    The result is an INTEGER value from 1 through 7, representing the day of the week, where Sunday = 1 and Saturday = 7.

    Usage Notes

    The td_day_of_week 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 October 18, 2010, which is a Monday, the following queries return the value 2 as the result since Monday is the 2nd day of the week.

       SELECT td_day_of_week(CURRENT_DATE);
     
       SELECT td_day_of_week(DATE '2010-10-18');