15.10 - INTERVAL DAY TO HOUR Data Type - Teradata Database

Teradata Database SQL Data Types and Literals

prodname
Teradata Database
vrm_release
15.10
category
Programming Reference
featnum
B035-1143-151K

Identifies a field as an INTERVAL value defining a period of time in days and hours.

where:

 

Syntax element …

Specifies …

precision

the permitted range of digits for DAY, ranging from one to four.

The default is two.

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 HOUR is ANSI SQL:2011 compliant.

Conceptually, INTERVAL DAY TO HOUR is a record with the following fields.

 

Field Name

Storage Format

Total Length

DAY

SMALLINT

4 bytes

HOUR

SMALLINT

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

 

Type

Format

CHARACTER(precision + 4)

'-d(precision) hh'

An example value of INTERVAL DAY (2) TO HOUR is ' 17 11'.

The range of values for INTERVAL DAY TO HOUR is as follows.

 

Type and Precision

Minimum Value

Maximum Value

INTERVAL DAY(1) TO HOUR

-'9 23'

'9 23'

INTERVAL DAY(2) TO HOUR

-'99 23'

'99 23'

INTERVAL DAY(3) TO HOUR

-'999 23'

'999 23'

INTERVAL DAY(4) TO HOUR

-'9999 23'

'9999 23'

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 HOUR column:

   CREATE TABLE TimeInfo 
     (Id INTEGER
     ,Offset INTERVAL DAY (4) TO HOUR);