15.00 - NUMTOYMINTERVAL - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)
Last Update
2018-09-24

NUMTOYMINTERVAL

Purpose  

Converts numeric_value into an INTERVAL YEAR(4) TO MONTH value.

Syntax  

where:

 

Syntax element …

Specifies …

TD_SYSFNLIB

the name of the database where the function is located.

numeric_value

a numeric argument.

If numeric_value is NULL, NULL is returned.

interval_unit

a character argument.

interval_unit specifies the unit of value for numeric_value. It must be one of the following case-insensitive values:

  • 'YEAR'
  • 'MONTH'
  • Any value that overflows the INTERVAL YEAR(4) TO MONTH value results in an error.

    If interval_unit is NULL, NULL is returned.

    ANSI Compliance

    This is a Teradata extension to the ANSI SQL:2011 standard.

    Invocation

    NUMTOYMINTERVAL is an embedded services system function. For information on activating and invoking embedded services functions, see “Embedded Services System Functions” on page 24.

    Argument Types and Rules

    Expressions passed to this function must have the following data types:

  • numeric_value = BYTEINT, SMALLINT, INTEGER, BIGINT, DECIMAL/NUMERIC, FLOAT/REAL/DOUBLE PRECISION, or NUMBER
  • exponent_value = CHAR OR VARCHAR
  • Result Type

    The return value data type is INTERVAL YEAR(4) TO MONTH.

    Example  

    The following query:

    SELECT NUMTOYMINTERVAL(40, 'YEAR'); 

    returns the result '40-00', which is 40 years, 0 months.

    Example  

    The following query:

    SELECT NUMTOYMINTERVAL(100, 'MONTHS'); 

    returns the result '08-04', which is 8 years, 4 months.