Identifies a field as an INTERVAL value defining a period of time in days, hours, and minutes.
where:
Syntax element … |
Specifies … |
precision |
the permitted range of digits for DAY, ranging from one to four. The default is two. HOUR is always two digits and MINUTE is always two digits. |
attributes |
appropriate data type, column storage, or column constraint attributes. See “Core Data Type Attributes” on page 17 and “Storage and Constraint Attributes” on page 18 for specific information. |
INTERVAL DAY TO MINUTE is ANSI SQL:2011 compliant.
Conceptually, INTERVAL DAY TO MINUTE is a record that has the following fields.
Field Name |
Storage Format |
Total Length |
DAY |
SMALLINT |
8 bytes (with 2 pad bytes) |
HOUR |
SMALLINT |
|
MINUTE |
SMALLINT |
INTERVAL DAY TO MINUTE types are imported and exported in record and indicator modes as CHARACTER data using the client character set.
Type |
Format |
CHARACTER(precision + 7) |
'-d(precision) hh:mm' |
For example, for INTERVAL DAY (3) TO MINUTE, the value might be something like '‑127 12:37'.
The range of values for INTERVAL DAY TO MINUTE is as follows.
Type and Precision |
Minimum Value |
Maximum Value |
INTERVAL DAY(1) TO MINUTE |
-'9 23:59' |
'9 23:59' |
INTERVAL DAY(2) TO MINUTE |
-'99 23:59' |
'99 23:59' |
INTERVAL DAY(3) TO MINUTE |
-'999 23:59' |
'999 23:59' |
INTERVAL DAY(4) TO MINUTE |
-'9999 23:59' |
'9999 23:59' |
Note: Decimal values are not allowed for Interval data types except for second intervals.
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 SQL Functions, Operators, Expressions, and Predicates.
The following statement creates a table with an INTERVAL DAY TO MINUTE column:
CREATE TABLE TimeInfo
(Id INTEGER
,Offset INTERVAL DAY (4) TO MINUTE);