Example: Intuitive Examples - Advanced SQL Engine - Teradata Database

SQL Date and Time Functions and Expressions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
dzx1591742169550.ditamap
dita:ditavalPath
dzx1591742169550.ditaval
dita:id
B035-1211
lifecycle
previous
Product Category
Teradata Vantageā„¢

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.