Definition of Normalization - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

The normalization process is explained more formally as follows.

When the DAY field of the source date_expression or timestamp_expression is greater than the resulting target DAY field, ADD_MONTHS sets DD equal to the last day of the month + n to normalize the reported date or timestamp.

Define date_expression as 'YYYY-MM-DD' for simplicity.

For a given date_expression, you can then express the syntax of ADD_MONTHS as follows.

ADD_MONTHS('YYYY-MM-DD' , n)

Recalling that n can be negative, and substituting 'YYYY-MM-DD' for date_expression, you can redefine ADD_MONTHS in terms of ANSI SQL:2011 dates and intervals as follows.

ADD_MONTHS('YYYY-MM-DD', n) = 'YYYY-MM-DD' ± INTERVAL 'n' MONTH

The equation is true unless a non valid date such as 1999-09-31 results, in which case the ANSI expression traps the nonvalid date exception and returns an error.

ADD_MONTHS processes the exception and returns a valid, though not necessarily expected, date. The algorithm ADD_MONTHS uses to produce its normalized result is as follows, expressed as pseudocode.

WHEN
DD > last_day_of_the_month(MM+n)
THEN SET
DD = last_day_of_the_month(MM+n)

This property is also true for the date portion of any timestamp_expression.

Normalization produces valid results for leap years.