CONVERT DATE

Syntax

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

Short Reference

Addition:

... DAYLIGHT SAVING TIME dst

Effect

This statement adopts a date specified in dat, a time specified in tim, and a daylight saving time selection specified in dst as the local date and time specification for the time zone specified in tz, converts it to the UTC reference time, and assigns the result to the time_stamp variable as a time stamp.

dat and tim must be data objects of the data type d or t. Data objects of other types are converted to d or t. If the TIME addition is not specified, the system implicitly uses the initial time "000000" for tim. If dat or tim contain invalid values, time_stamp is not changed and sy-subrc is set to 12. In tim, only the values 00 to 23 are valid for hours, and 00 to 59 for minutes and seconds.

tz must be a data object with type TIMEZONE from the ABAP Dictionary that contains a time zone from the column TZONE of the database table TTZZ in uppercase. If tz is initial, the time specified in dat and tim is adopted as the UTC reference time and sy-subrc is set to 4. If the specified time zone is not found in the database table TTZZ, time_stamp remains unchanged and sy-subrc is set to 8. If the rule set for the specified time zone is not complete, an exception that cannot be handled is raised.

The data object time_stamp must have either the data type TIMESTAMP or TIMESTAMPL from the ABAP Dictionary and be of ABAP type p with length 8 or p with length 11 and have seven decimal places. If time_stamp is of data type TIMESTAMPL for the long form, the second fractions in the decimal places are initialized during assignment.

System Fields

sy-subrc Meaning
0 Local time of specified time zone was converted to time stamp and assigned to the target field.
4 Time specification was converted to time stamp without time offset and assigned to the target field.
8 Time specification could not be converted, because the specified time zone is not in the database table TTZZ.
12 Time specification could not be converted, because dat, tim, or dst contain invalid or inconsistent values.

Addition

... DAYLIGHT SAVING TIME dst

Effect

As of Release 6.20, the DAYLIGHT SAVING TIME addition can be specified after TIME. For dst you must specify a data object of the type c with the length 1 that must have the value "X" or " ". If dst has the value "X", the value of tim is adopted as the time specification in daylight saving time. If dst has the value " ", the value of tim is adopted as the time specification in winter time. If dst has a different value or the specified value does not suit the value in tim and dat, the time_stamp remains unchanged and sy-subrc is set to 12. If the DAYLIGHT SAVING TIME addition is not specified, the value of dst is implicitly set to "X" in daylight saving time and " " in winter time for specifications in tim und dat. In the extra hour that arises when switching from daylight saving time to wintertime, dst is set to "X" and the specification in tim and dat is adopted as the time specification in daylight saving time.

Notes

Example

For the time zone "BRAZIL", the settings described in the example for CONVERT TIME STAMP apply to the rule set for time stamps. By specifying the daylight saving and winter time (as of Release 6.20) two different UTC time stamps "20030309033000" and "20030309043000" are created from one local time specification. Without the addition DAYLIGHT SAVING TIME, the UTC time stamp "20030309033000" is created.

DATA: time_stamp TYPE timestamp,
      dat TYPE d,
      tim TYPE t,
      tz  TYPE ttzz-tzone.

tz = 'BRAZIL'.
dat = '20030309'.
tim = '013000'.

CONVERT DATE dat TIME tim DAYLIGHT SAVING TIME 'X'
        INTO TIME STAMP time_stamp TIME ZONE tz.
WRITE: / time_stamp.

CONVERT DATE dat TIME tim DAYLIGHT SAVING TIME ' '
        INTO TIME STAMP time_stamp TIME ZONE tz.
WRITE: / time_stamp.

Exceptions

Non-Catchable Exceptions