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

Teradata Vantage™ - SQL Date and Time Functions and Expressions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1211-171K
Language
English (United States)

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