Normalization Behavior of ADD_MONTHS - 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 standard approach to interval month arithmetic is to increment MONTH and YEAR values as appropriate and retain the source value for DAY. This is a problem for the case when the target DAY value is smaller than the source DAY value from the source date.

For example, what approach should be taken to handle the result of adding one MONTH to a source DATE value of ‘1999-01-31’? Using the standard approach, the answer would be ‘1999-02-31’, but February 31 is not a valid date.

The behavior of ADD_MONTHS is equivalent to that of the ANSI SQL:2011 compliant operations DATE ± INTERVAL ‘n’ MONTH and TIMESTAMP ± INTERVAL ‘n’ MONTH with one important difference.

The difference between these two scalar arithmetic operations is their behavior when a non-valid date value is returned by the function.
  • ANSI SQL:2011 arithmetic returns an error.
  • ADD_MONTHS arithmetic makes normative adjustments and returns a valid date.