17.00 - 17.05 - Example: Intuitive Examples - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Date and Time Functions and Expressions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
17.05
Release Date
June 2020
Content Type
Programming Reference
Publication ID
B035-1211-170K
Language
English (United States)

The examples are simple, intuitive examples of the ADD_MONTHS function. All results are both valid and expected.

Example: Querying the Number of Months in Years to a DATE Expression

This statement returns the current date plus 13 years.

SELECT ADD_MONTHS (CURRENT_DATE, 12*13);

Example: Querying for the Current Date Plus Six Months

This statement returns the date 6 months ago.

SELECT ADD_MONTHS (CURRENT_DATE, -6);

Example: Querying for the Current Date Plus Four Months

This statement returns the current TIMESTAMP plus four months.

SELECT ADD_MONTHS (CURRENT_TIMESTAMP, 4);

Example: Querying for the Current Date Plus Nine Months

This statement returns the TIMESTAMP nine months from January 1, 1999. Note the literal form, which includes the keyword TIMESTAMP.

SELECT ADD_MONTHS (TIMESTAMP '1999-01-01 23:59:59', 9);

Example: Querying for the Current Date Plus One Month

This statement adds one month to January 30, 1999.

SELECT ADD_MONTHS ('1999-01-30', 1);

The result is 1999-02-28.