Arithmetic Operators | SQL Date/Time Functions & Expressions | Teradata Vantage - Arithmetic Operators - Advanced SQL Engine - Teradata Database

SQL Date and Time Functions and Expressions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
xmd1556127764262.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1211
lifecycle
previous
Product Category
Teradata Vantageā„¢

Adds or subtracts an Interval value to or from a Period value, or adds a Period value to an Interval value.

Syntax

period_expression {+|-} interval_expression
The order of period_expression and interval_expression is not important.
period_expression

The Period expression to be converted.

Any expression that evaluates to a Period data type.

interval_expression

An expression that evaluates to an INTERVAL data type.

Assuming that p is a Period expression of element type DATE or TIMESTAMP and v is an Interval expression:
  • p + v and v + p are both equivalent to:
    PERIOD(BEGIN(p) + v, CASE WHEN END(p) IS UNTIL_CHANGED THEN END(p) ELSE (END(p) + v) END)
  • p - v is equivalent to:
    PERIOD(BEGIN (p) - v, CASE WHEN END(p) IS UNTIL_CHANGED THEN END(p) ELSE (END(p) - v) END)
Assuming that p is a Period expression of element type TIME and v is an interval expression:
  • p + v and v + p are both equivalent to:
    PERIOD(BEGIN(p) + v, END(p) + v)
  • p - v is equivalent to:
    PERIOD(BEGIN (p) - v, END(p) - v)