INTERVAL YEAR Data Type | Data Types and Literals | Teradata Vantage - INTERVAL YEAR Data Type - Advanced SQL Engine - Teradata Database

SQL Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
zsn1556242031050.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1143
lifecycle
previous
Product Category
Teradata Vantage™

Identifies a field as an INTERVAL value defining a period of time in years.

Syntax

INTERVAL YEAR [ ( precision ) ] [ attributes [...] ]
precision
The permitted range of digits for YEAR, ranging from 1 to 4.
The default is 2.
For example, if you specify a precision of 4, the range for YEAR is -'9999' through '9999'.
attributes
Appropriate data type, column storage, or column constraint attributes.
For specific information, see Core Data Type Attributes and Storage and Constraint Attributes.

ANSI Compliance

INTERVAL YEAR is ANSI SQL:2011 compliant.

Internal Representation of INTERVAL YEAR

Storage Format Length
SMALLINT 2 bytes

External Representation of INTERVAL YEAR

INTERVAL YEAR types are imported and exported in record and indicator modes as CHARACTER data using the client character set.

Type Format
CHARACTER(precision + 1) '-y(precision)'

The value includes a leading blank or minus sign followed by the indicated number of digits. An example value for INTERVAL YEAR(3) is '-125'.

Range of Values

The range of values for INTERVAL YEAR is as follows.

Type and Precision Minimum Value Maximum Value
INTERVAL YEAR(1) -'9' '9'
INTERVAL YEAR(2) -'99' '99'
INTERVAL YEAR(3) -'999' '999'
INTERVAL YEAR(4) -'9999' '9999'
Decimal values are not allowed for Interval data types except for second intervals.

Implicit and Explicit INTERVAL YEAR Conversion

Teradata Database performs implicit conversion from one Interval data type to another Interval type in some cases. You can also use CAST to explicitly convert one Interval type to another.

Conversions are possible only within the same INTERVAL family. For example, you may convert a YEAR interval to months, but not to days or hours.

For more information, see “Data Type Conversions” in Teradata Vantage™ - SQL Functions, Expressions, and Predicates, B035-1145.