Example of interval_term / numeric_factor - Advanced SQL Engine - Teradata Database

SQL Date and Time Functions and Expressions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
dzx1591742169550.ditamap
dita:ditavalPath
dzx1591742169550.ditaval
dita:id
B035-1211
lifecycle
previous
Product Category
Teradata Vantageā„¢

The following example uses an interval_term value divided by a numeric_factor value.

SELECT INTERVAL '10-03' YEAR TO MONTH / 3;

The interval_term is INTERVAL '10-03' YEAR TO MONTH.

The numeric_factor is 3.

The processing involves the following stages:

  1. The interval value is decomposed into a value of months.

    Ten years and three months evaluate to 123 months.

  2. The interval total is divided by the numeric_factor 3, giving '3-05'.

The next example is similar to the first except that it shows how truncation is used in integer arithmetic.

SELECT INTERVAL '10-02' YEAR TO MONTH / 3;

The interval_term is INTERVAL '10-02' YEAR TO MONTH.

The numeric_factor is 3.

The processing involves the following stages:

  1. The interval value is decomposed into a value of months.

    Ten years and two months evaluate to 122 months.

  2. The interval total is divided by the numeric_factor 3, giving 40.67 months, which is truncated to 40 because the value is an integer.
  3. The interval total is converted back to the appropriate format, giving INTERVAL '3-04'.