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

CONVERT INTO TIME STAMP

Quick Reference

Syntax

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


Effect

This statements converts a date specified in dat, a time specified in tim, and a summer time marker specified in dst from the time zone specified in tz into a time stamp and maps the result to the variable time_stamp.

dat, tim, dst, and tz are functional operand positions.

If the time zone specified in tz does not have a summer time rule (for example when "UTC" is specified), the addition DAYLIGHT SAVING TIME is ignored. If the addition DAYLIGHT SAVING TIME is not specified, the value of dst is set to "X" implicitly if the data in tim and dat is in summer time and is set to " " for data in winter time. In the extra hour that is caused by switching from summer time to winter time, tim and dat are interpreted as a time in summer time and dst is set to the value "X". If the value in dst does not match the data in tim and dat (that is, if the value "X" is specified in winter time and the value " " in summer time, time_stamp is not changed and sy-subrc is set to 12.

The following can be specified for time_stamp:

When dates 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).

If dat and tim contain valid values but produce an invalid time stamp when combined with a valid time zone in tz, time_stamp is not modified and sy-subrc is set to 12.

System Fields

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

Notes

Example

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

DATA: 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 DATA(time_stamp) TIME ZONE tz.
cl_demo_output=>write_data( time_stamp ).

CONVERT DATE dat TIME tim DAYLIGHT SAVING TIME ' '
        INTO TIME STAMP time_stamp TIME ZONE tz.
cl_demo_output=>write_data( time_stamp ).

cl_demo_output=>display( ).

Exceptions

Non-Handleable Exceptions