Reference Guide > TDV SQL Support > Data Types > INTERVAL YEAR
 
INTERVAL YEAR
INTERVAL YEAR represents a unit of time that is measured in months and years. It can be expressed in years only, months only, or both year and months.
INTERVAL YEAR (which includes months) is not compatible with INTERVAL DAY, because a year can have 365 or 366 days, and a month can have 28, 29, 30, or 31 days.
Syntax
INTERVAL 'yy' YEAR [TO MONTH]
INTERVAL 'mm' MONTH
INTERVAL 'yy-mm' YEAR TO MONTH
 
Negative intervals can be represented in any of three formats:
-INTERVAL 'mm' MONTH
INTERVAL '-mm' MONTH
INTERVAL -'mm' MONTH
Remarks
A dash separates the year and month values.
In a year-month interval, the month value must not be greater than 11.
The three formats for negative intervals can be intermixed. For example, the following resolves to an interval of -3 months:
-INTERVAL -'-3' MONTH
 
Default precision is 2. For example, the following expressions are equivalent:
INTERVAL '99' YEAR
INTERVAL '99' YEAR(2)
 
The precision indicates the maximum number of digits in the leading number. For example, the expression below is invalid because its length exceeds the 2-digit precision in the year value.
INTERVAL '2001' YEAR(2)
 
In a year-month interval, the precision applies only to the year:
INTERVAL '2001-09' YEAR(4) TO MONTH
 
The maximum precision for years is 9 digits.
For details on using INTERVAL YEAR in arithmetic operations and functions, see:
Arithmetic Operators
CAST
EXTRACT
ABS