CONVERT TIME STAMP

Short Reference

Syntax

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

Addition:

... DAYLIGHT SAVING TIME dst

Effect

This statement interprets a time stamp specified in time_stamp as a UTC reference time, converts it to the local date and local time of the time zone specified in tz and assigns the result to the dat, tim and dst variables. At least one of the two additions DATE or TIME must be specified.

The time_stamp data object must have either the data type TIMESTAMP, or TIMESTAMPL from the ABAP Dictionary and the corresponding ABAP type p of length 8 or p of length 11 with seven fractional portions, and which contains one valid time stamp in short or long form. If time_stamp does not contain a valid time stamp, the content of dat and tim is not changed, and sy-subrc is set to 12.

For tz, a data object of type TIMEZONE from the ABAP Dictionary must be specified, which contains a time zone from the TZONE column of the TTZZ database table in uppercase. If tz is initial, no local time is calculated; instead, dat and tim are assigned to the UTC reference time and sy-subrc is set to 4. If the specified time zone is not found in database table TTZZ, the content of dat and tim remains unchanged and sy-subrc is set to 8. If the rules for the specified time zone are not complete, this results in an untreatable exception.

The return values for dat and tim are of data type d or t. For dat and tim, suitable data objects have to be specified, which the return values can be converted into. If the time stamp in time_stamp is available in long form, then the fractions of seconds in the fractional portions are ignored.

System Fields

sy-subrc Meaning
0 Time stamp was converted into the local time of the specified time zome 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 since the specified time zone is not available in database table TTZZ.
12 Time stamp could not be converted since time_stamp contains an invalid value.

Addition

... DAYLIGHT SAVING TIME dst

Effect

A dst variable of type c of length 1 must be specified after the optional DAYLIGHT SAVING TIME addition. If the time stamp contained in time_stamp for the time zone specified in tz is in the summer, then dst is set to "X". If it is not, it is set to " " (seit Release 6.20).

Notes

Example

For the "BRAZIL" time zone available in database table TTZZ, a shift of -3 hours against 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 corresponds to March 9th. 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 (from Release 6.20).

DATA: time_stamp TYPE timestamp,
      dat        TYPE d,
      dat        TYPE d,
      tz         TYPE ttzz-tzone,
      dst        TYPE c LENGTH 1.

tz = 'BRAZIL'.
time_stamp = 20030309033000.
CONVERT TIME STAMP time_stamp TIME ZONE tz
        INTO DATE dat TIME tim DAYLIGHT SAVING TIME dst.
WRITE: /(10) dat, (8) tim, dst.

time_stamp = 20030309043000.
CONVERT TIME STAMP time_stamp TIME ZONE tz
        INTO DATE dat TIME tim DAYLIGHT SAVING TIME dst.
WRITE: /(10) dat, (8) tim, dst.

Exceptions

Non-Catchable Exceptions