Example of numeric_term * ± interval_primary - 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™

This example multiplies a negative interval_primary by a numeric_term and adds the negative result to an interval_term.

SELECT (RACE_DURATION + (2 * INTERVAL -'30' DAY));

The numeric_term in this case is the numeric_primary 2.

The interval_primary is INTERVAL -'30' DAY.

RACE_DURATION is an interval_term, with type INTERVAL DAY TO SECOND.

The processing involves the following stages:

  1. The interval_primary is converted to an exact numeric, or 60 days.
  2. The operations indicated in the arithmetic are performed on the operands (which are both numeric at this point), producing an exact numeric result having the appropriate scale and precision.

    In this example, 60 days are subtracted from RACE_DURATION, which is an INTERVAL type of INTERVAL DAY TO SECOND.

  3. The numeric result is converted back into the indicated INTERVAL type, DAY TO SECOND.