td_quarter_of_year - Teradata Database

SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Language
English (United States)
Last Update
2018-09-24
dita:id
B035-1145
lifecycle
previous
Product Category
Teradata® Database

td_quarter_of_year

Purpose  

Returns the quarter number of the year for the specified date.

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.

ANSI Compliance

This is a Teradata extension to the ANSI SQL:2011 standard.

Argument Types

td_quarter_of_year 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 to 4, representing the quarter number from the beginning of the year, where 1 = first quarter (Jan/Feb/Mar) and 4 = fourth quarter (Oct/Nov/Dec).

    Usage Notes

    The td_quarter_of_year 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 November 14, 1983, the following queries return the value 4 as the result since November 14, 1983 falls on the 4th quarter of the year.

       SELECT td_quarter_of_year(CURRENT_DATE);
     
       SELECT td_quarter_of_year(DATE '1983-11-14');