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

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 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.