Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Date and Time Processing →  Time Stamp 

Time Stamps - Overview

Other versions: 7.31 | 7.40 | 7.54

Representation of Time Stamps

Time stamps are represented using packed numbers of the type p. There is a short form and a long form.

  • In the short form, a time stamp is represented precisely to the second using a packed number with length 8, and the ABAP Dictionary type TIMESTAMP. The digits of the packed number show the time stamp in the format "yyyymmddhhmmss", where "yyyy" is the year, "mm" is the month, "dd" is the day, "hh" is the hour, "mm" are the minutes, and "ss" are the seconds.
  • In the long form, a time stamp is represented precisely to 100 ns using a packed number with length 11 and seven decimal places, and the ABAP Dictionary type TIMESTAMPL The digits of the packed number show the time stamp in the format "yyyymmddhhmmss.sssssss", where, in addition to the short form, the seven decimal places "sssssss" are the fractions of a second. The maximum time resolution depends on the operating system of the application server and can be less.

A valid time time stamp must contain valid date and time information before the decimal separator:

  • When specifying the date, only the values 01 to 9999 for the year, 01 to 12 for the month, and 01 to 31 for the day are valid.
  • When specifying the time, only the values 00 to 23 for the hours, and 00 to 59 for the minutes and seconds are valid.

A time valid in the Gregorian calendar must be represented. Leap seconds are not supported.

Access to Time Stamps

Only a few statements recognize that packed numbers of the types TIMESTAMP and TIMESTAMPL are time stamps. All other statements interpret the content of these data types numerically and are not suitable for handling time stamps. The following statements can be used to handle time stamps:

The following settings for formatting output also handle time stamps in a specific way:

  • Use of the addition TIME ZONE of the statement WRITE [TO].

The system class CL_ABAP_TSTMP provides methods for adding, subtracting, converting, and comparing time stamps.

Notes on Handling Time Stamps

Time stamps are only interpreted as such when they are accessed by the statements, methods, and functions listed above. When being assigned or converted, they behave like packed numbers of the type p. Therefore, time stamps are not suitable for direct calculations. Comparisons produce a meaningful result only when two time stamps are compared with each other. In programs for which the program attribute Fixed Point Arithmetic is not set, note the rules applying to the data type p. In particular, direct comparisons of time stamps in the long form with the short form produce a meaningful result only when the program attribute fixed point arithmetic is set. Otherwise, you must use system class CL_ABAP_TSTMP for comparisons as well. When assigning time stamps in the long form to time stamps in the short form, unwanted rounding effects occur. For this reason, always use the method MOVE of the system class CL_ABAP_TSTMP.

When time stamps are used in operand positions where they are not supposed to be used, no warnings are given by the syntax check or by the extended program check (not even for the statement MOVE EXACT).