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

CONVERT TIME STAMP  Syntax Diagram

Short Reference

Syntax

CONVERT TIME STAMP time_stamp TIME ZONE tz
        INTO [DATE dat]
             [TIME tim] [DAYLIGHT SAVING TIME dst].

Effect

This statement interprets the content of time_stamp as a time stamp, converts it to the local data and the local time in the time zone specified in tz, and assigns the result to the variables dat, tim, and dst.

time_stamp and tz are functional operand positions.

The following applies to the return values dat, tim, and dst:

When time stamps are converted to reflect the conversion from the Julian calendar to the Gregorian calendar and the non-existence of the days between 19/5/1582 and 10/14/1582, this returns the same results as the conversion for the days from 10/15/1582 to 10/24/1582 (which do exist).

System Fields

sy-subrc Meaning
0 Time stamp was converted into the local time of the specified time zone and assigned to the target fields.
4 Time stamp was assigned to the target fields without conversion into the local time.
8 Time stamp could not be converted, because the specified time zone is not in the database table TTZZ.
12 Time stamp could not be converted since time_stamp contains an invalid value.

Notes

Example

For the time zone "BRAZIL" in database table TTZZ, a shift of -3 hours from the UTC reference time is entered in database table TTZR. The end of the summer time is defined in database table TTZDV as the second Sunday in March at 02:00, which in the year 2003 is March 9. With these settings in the rules, the two conversions below both result in the same local time of "01:30:00". The first conversion shows that the time is still in the summer time.

DATA: time_stamp     TYPE timestamp,
      tz  TYPE ttzz-tzone.

tz = 'BRAZIL'.
time_stamp = 20030309033000.
CONVERT TIME STAMP time_stamp TIME ZONE tz
        INTO DATE DATA(dat) TIME DATA(tim)
        DAYLIGHT SAVING TIME DATA(dst).
cl_demo_output=>write( |{ dat DATE = ISO } {
                          tim TIME = ISO } { dst }| ).

time_stamp = 20030309043000.
CONVERT TIME STAMP time_stamp TIME ZONE tz
        INTO DATE dat TIME tim
        DAYLIGHT SAVING TIME dst.
cl_demo_output=>write( |{ dat DATE = ISO } {
                          tim TIME = ISO } { dst }| ).

cl_demo_output=>display( ).

Exceptions

Non-Catchable Exceptions