Example: Intuitive Examples - Analytics Database - Teradata Vantage

SQL Date and Time Functions and Expressions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2023-10-30
dita:mapPath
cpk1628111786971.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
pxz1544241488545
lifecycle
latest
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.