Timestamp Data Type

Timestamp fields have a predetermined size and format. They can be defined on the definition specification. Timestamp data must be in the form YYYY-MM-DD-hh-mm, optionally followed by 1 to 12 fractional seconds.

The default size of a timestamp is 26, with 6 fractional seconds. For a free-form timestamp definition, you use the parameter of the TIMESTAMP keyword to control the number of fractional seconds. For a fixed-form timestamp definition, you can either specify the length of the timestamp item as 19, or a value between 21 and 32, or you can specify the number of fractional seconds in the Decimal Positions entry. In the following example, items ts1 and ts3 have 6 fractional seconds. Item ts2 has 3 fractional seconds. Item ts4 has 7 fractional seconds. Item ts5 has 2 fractional seconds.

    DCL-S ts1 TIMESTAMP;
    DCL-S ts2 TIMESTAMP(3);
D ts3             S               Z
D ts4             S             27Z
D ts5             S               Z 2

You can specify between 0 and 12 fractional seconds for timestamp literals. However, timestamp literals have between 6 and 12 fractional seconds. If fewer than 6 fractional seconds are specified for a literal, the timestamp will be padded on the right with zeros so that it has 6 fractional seconds. See Literals for more information about timestamp literals.

Leading zeros are required for all timestamp data.

The default initialization value for a timestamp is midnight of January 1, 0001 (0001-01-01-00.00.00 with zero fractional seconds). The *HIVAL value for a timestamp is 9999-12-31-24.00.00 with zero fractional seconds. The *LOVAL value for timestamp is 0001-01-01-00.00.00 with zero fractional seconds.