16.20 - Conversions That Include Fractional Seconds - Teradata Vantage NewSQL Engine

Teradata Vantageā„¢ Data Types and Literals

Teradata Database
Teradata Vantage NewSQL Engine
March 2019
Programming Reference

The following rules apply to conversions that include fractional seconds:

  • The fractional seconds precision in the source character string must be less than or equal to the fractional seconds precision specified by the target type.
    SELECT CAST('12:30:25.44' AS TIME(3));

    If no fractional seconds appear in the source character string, then the fractional seconds precision is always less than or equal to the target data type fractional seconds precision, because the valid range for the precision is zero to six, where the default is six.

    SELECT CAST('12:30:25' AS TIME(3));
  • If the target data type is defined by a FORMAT phrase, the fractional seconds precision formatting characters must be greater than or equal to the precision specified by the data type.
    SELECT CAST('12h:15.12s:30m' 
    AS TIME(4) FORMAT 'HHh:SSDS(4)s:MIm');

    A FORMAT phrase must specify a fractional seconds precision of six if the target data type does not specify a fractional seconds precision, because the default precision is six.

    SELECT CAST ('12:30:25' AS TIME FORMAT 'HH:MI:SSDS(6)');