16.20 - INTERVAL HOUR TO SECOND Data Type - Teradata Vantage NewSQL Engine

Teradata Vantage™ Data Types and Literals

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1143-162K

Purpose

Identifies a field as an INTERVAL value defining a period of time in hours, minutes, and seconds.

Syntax



precision
The permitted range of digits for HOUR, ranging from one to four.
The default is two.
fractional_seconds_precision
The fractional precision for the values of SECOND, ranging from zero to six.
The default is six.
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 HOUR TO SECOND is ANSI SQL:2011 compliant.

Internal Representation of INTERVAL HOUR TO SECOND

Conceptually, INTERVAL HOUR TO SECOND has the following fields.

Field Name Storage Format Total Length
HOUR SMALLINT 8 bytes
MINUTE SMALLINT
SECOND INTEGER

External Representation of INTERVAL HOUR TO SECOND

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

WHEN fractional_seconds_precision is … THEN the type and format are …
0 Type: CHARACTER(precision + 7)
Format: '-h(precision):mm:ss'
n

where n is 1 - 6

Type: CHARACTER(precision + n + 8)
Format: '-h(precision):mm:ss.s(n)'

For example, for INTERVAL HOUR(2) TO SECOND(2), the value might be something like '-13:27:58.17'.

Range of Values

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

Type, Precision, and Fractional Seconds Precision Minimum Value Maximum Value
INTERVAL HOUR(1) TO SECOND(0) -'9:59:59' '9:59:59'
INTERVAL HOUR(1) TO SECOND(1) -'9:59:59.9' '9:59:59.9'
INTERVAL HOUR(1) TO SECOND(2) -'9:59:59.99' '9:59:59.99'
INTERVAL HOUR(1) TO SECOND(3) -'9:59:59.999' '9:59:59.999'
INTERVAL HOUR(1) TO SECOND(4) -'9:59:59.9999' '9:59:59.9999'
INTERVAL HOUR(1) TO SECOND(5) -'9:59:59.99999' '9:59:59.99999'
INTERVAL HOUR(1) TO SECOND(6) -'9:59:59.999999' '9:59:59.999999'
INTERVAL HOUR(2) TO SECOND(0) -'99:59:59' '99:59:59'
INTERVAL HOUR(2) TO SECOND(1) -'99:59:59.9' '99:59:59.9'
INTERVAL HOUR(2) TO SECOND(2) -'99:59:59.99' '99:59:59.99'
INTERVAL HOUR(2) TO SECOND(3) -'99:59:59.999' '99:59:59.999'
INTERVAL HOUR(2) TO SECOND(4) -'99:59:59.9999' '99:59:59.9999'
INTERVAL HOUR(2) TO SECOND(5) -'99:59:59.99999' '99:59:59.99999'
INTERVAL HOUR(2) TO SECOND(6) -'99:59:59.999999' '99:59:59.999999'
INTERVAL HOUR(3) TO SECOND(0) -'999:59:59' '999:59:59'
INTERVAL HOUR(3) TO SECOND(1) -'999:59:59.9' '999:59:59.9'
INTERVAL HOUR(3) TO SECOND(2) -'999:59:59.99' '999:59:59.99'
INTERVAL HOUR(3) TO SECOND(3) -'999:59:59.999' '999:59:59.999'
INTERVAL HOUR(3) TO SECOND(4) -'999:59:59.9999' '999:59:59.9999'
INTERVAL HOUR(3) TO SECOND(5) -'999:59:59.99999' '999:59:59.99999'
INTERVAL HOUR(3) TO SECOND(6) -'999:59:59.999999' '999:59:59.999999'
INTERVAL HOUR(4) TO SECOND(0) -'9999:59:59' '9999:59:59'
INTERVAL HOUR(4) TO SECOND(1) -'9999:59:59.9' '9999:59:59.9'
INTERVAL HOUR(4) TO SECOND(2) -'9999:59:59.99' '9999:59:59.99'
INTERVAL HOUR(4) TO SECOND(3) -'9999:59:59.999' '9999:59:59.999'
INTERVAL HOUR(4) TO SECOND(4) -'9999:59:59.9999' '9999:59:59.9999'
INTERVAL HOUR(4) TO SECOND(5) -'9999:59:59.99999' '9999:59:59.99999'
INTERVAL HOUR(4) TO SECOND(6) -'9999:59:59.999999' '9999:59:59.999999'

Implicit and Explicit INTERVAL HOUR TO SECOND 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.