17.10 - Examples - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - Data Types and Literals

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

Example: Converting string_value Specified as an SQL Interval Format

The following query, which specifies an SQL interval format:

SELECT TO_YMINTERVAL('04-10'); 

returns the result '04-10'.

Example: Converting string_value Specified as an ISO duration

The following query, which specifies an ISO duration:

SELECT TO_YMINTERVAL('P100Y4M'); 

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

Example: string_value Error

The following query:

SELECT TO_YMINTERVAL('P20Y3M4DT12H23M34.234S');

returns an error because only the P, Y, and M designators are allowed.

Example: Converting string_value Specified as an ISO duration of -14 months

The following query, which specifies an ISO duration of -14 months:

SELECT TO_YMINTERVAL('-P14M'); 

returns the result '-01-02', which is negative 1 year, 2 months.