## Purpose

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

## Syntax

- precision
- The permitted range of digits for SECOND, ranging from one to four.
- fractional_seconds_precision
- The fractional precision for the values of SECOND, ranging from zero to six.
- attributes
- Appropriate data type, column storage, or column constraint attributes.

## ANSI Compliance

INTERVAL SECOND is ANSI SQL:2011 compliant.

## Internal Representation of INTERVAL SECOND

Conceptually, the internal representation of INTERVAL SECOND consists of the following fields.

Field Name | Storage Format | Total Length |
---|---|---|

WHOLE SECONDS | SMALLINT | 6 bytes |

FRACTIONAL SECONDS | INTEGER |

## External Representation of INTERVAL SECOND

INTERVAL 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 + 1) |

Format: '-s(precision)' | |

n
where n is 1 - 6 |
Type: CHARACTER(precision + n + 2) |

Format: '-s(precision).s(n)' |

For example, for INTERVAL SECOND(3,2), the value might be something like '-127.35'.

## Range of Values

The range of values for INTERVAL SECOND is as follows.

Type, Precision, and Fractional Seconds Precision | Minimum Value | Maximum Value |
---|---|---|

INTERVAL SECOND(1,0) | -'9' | '9' |

INTERVAL SECOND(1,1) | -'9.9' | '9.9' |

INTERVAL SECOND(1,2) | -'9.99' | '9.99' |

INTERVAL SECOND(1,3) | -'9.999' | '9.999' |

INTERVAL SECOND(1,4) | -'9.9999' | '9.9999' |

INTERVAL SECOND(1,5) | -'9.99999' | '9.99999' |

INTERVAL SECOND(1,6) | -'9.999999' | '9.999999' |

INTERVAL SECOND(2,0) | -'99' | '99' |

INTERVAL SECOND(2,1) | -'99.9' | '99.9' |

INTERVAL SECOND(2,2) | -'99.99' | '99.99' |

INTERVAL SECOND(2,3) | -'99.999' | '99.999' |

INTERVAL SECOND(2,4) | -'99.9999' | '99.9999' |

INTERVAL SECOND(2,5) | -'99.99999' | '99.99999' |

INTERVAL SECOND(2,6) | -'99.999999' | '99.999999' |

INTERVAL SECOND(3,0) | -'999' | '999' |

INTERVAL SECOND(3,1) | -'999.9' | '999.9' |

INTERVAL SECOND(3,2) | -'999.99' | '999.99' |

INTERVAL SECOND(3,3) | -'999.999' | '999.999' |

INTERVAL SECOND(3,4) | -'999.9999' | '999.9999' |

INTERVAL SECOND(3,5) | -'999.99999' | '999.99999' |

INTERVAL SECOND(3,6) | -'999.999999' | '999.999999' |

INTERVAL SECOND(4,0) | -'9999' | '9999' |

INTERVAL SECOND(4,1) | -'9999.9' | '9999.9' |

INTERVAL SECOND(4,2) | -'9999.99' | '9999.99' |

INTERVAL SECOND(4,3) | -'9999.999' | '9999.999' |

INTERVAL SECOND(4,4) | -'9999.9999' | '9999.9999' |

INTERVAL SECOND(4,5) | -'9999.99999' | '9999.99999' |

INTERVAL SECOND(4,6) | -'9999.999999' | '9999.999999' |

## Implicit and Explicit INTERVAL 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.

## Example: INTERVAL SECOND Data Type

The following statement creates a table with an INTERVAL SECOND column:

CREATE TABLE TimeInfo (Id INTEGER ,Offset INTERVAL SECOND (2,3)); INSERT TimeInfo (1001, INTERVAL -'15.244' SECOND);