Timestamp strings

A string representation of a timestamp is a character or a Unicode graphic string that starts with a digit and has a length of at least 14 characters.

The complete string representation of a timestamp has one of the following forms:

Table 1. Formats for String Representations of Timestamps
Format Name Time Format Example
ISO timestamp Start of change'yyyy-mm-dd hh:mm:ss.nnnnnnnnnnnn'End of change '1990-03-02 08:30:00.010000000000'
IBM® SQL Start of change'yyyy-mm-dd-hh.mm.ss.nnnnnnnnnnnn'End of change '1990-03-02-08.30.00.010000000000'
Start of change14-26 character formEnd of change Start of change'yyyymmddhhmmssnnnnnnnnnnnn'End of change Start of change'19900302083000'End of change
Start of changeThe following rules apply:
  • Leading blanks are not allowed.
  • Trailing blanks can be included.
  • Leading zeros can be omitted from the month, day, hour, minute, and second part of the timestamp when using the timestamp form with separators. An implicit specification of 0 is assumed for any digit that is omitted.
  • The hour can be 24 if the minutes, seconds, and any fractional seconds are all zeros.
  • Trailing zeros can be truncated or omitted entirely from fractional seconds.
  • The number of digits of fractional seconds can vary from 0 to 12. An implicit specification of 0 is assumed if fractional seconds are omitted.
  • The separator character that follows the seconds element can be omitted if fractional seconds are not included.
End of change

Start of changeIf a string representation of a timestamp is implicitly cast to a value with a TIMESTAMP data type, the timestamp precision of the result of the cast is determined by the operation. Digits in the string beyond the timestamp precision of the cast are truncated or any missing digits needed to reach the timestamp precision of the cast are assumed to be zeros. For example 1990-3-2-8.30.00 is equivalent to 1990-03-02-8.30.00.000000000000. A string representation of a timestamp can be given a different timestamp precision by explicitly casting the value to a timestamp with a specified precision. In the case of a constant, the precision can be maintained by preceding the string with the TIMESTAMP keyword. For example, TIMESTAMP ’2007-03-28-14.50.35.123’ has the TIMESTAMP(3) data type.End of change