Skip to Content
Author's profile photo Himanshu Gupta

ABAP/4 & Date, Time and Timestamps

Implementation of Date

Date is implemented in SAP as CHARACTER*8 with implicit conversion exits.

Elementary data type     = D            Internal length = output length = 8

System data type     = DATS      Internal length = 8 output length = 10

Both the data types has no restriction on the actual value being stored but conversion-exists always treats the date in format ‘YYYYMMDD’.

Most of the times both type ‘D’ and ‘DATS’ behaves similarly except when they are output without any overriding additions. In such cases a ‘DATS’ type variable will be output with separators as specified in the “Date Format Settings” while a type ‘d’ variable will be output without separators.

Date Output Formats

Settings used to format the date can be supplied in 3 ways,

1.     USER setting                – Transaction SU3

a.     USER setting is the default setting used by SAP for output

2.     LOCALE/COUNTRY setting    – Transaction OY01

a.     Use command SET COUNTRY   Returns the timestamp in short or long form. The short form contains the current date and time; the long form also contains seven decimal places for fractions of a second, making the timestamp accurate to within 100 nanoseconds. 

Time Zone

the world is divided into 24 time zones spaced at intervals of 15 degrees in longitude. The zones start at 0 with Greenwich. Within each time zone, the hour and minute of the day is defined to be the same. Time zones are usually specified by the number of hours they differ from GMT

TTZCU   Customizing time zones table.

DST : Daylight Saving Time gives us the opportunity to enjoy sunny summer evenings by moving our clocks an hour forward in the spring.

Note :

Simple write statement is not going to put Timestamp in the desired output format. One has to specify a TIME ZONE for output formatting.

Transaction STZBD is used can be to maintain time zones .

1.     TTZZ     : Time zones

2.     TTZR     : Time zone rules

3.     TTZD     : Summer time rules (Daylight saving).

4.     TTZDF : Summer time rules (fixed annual dates)

5.     TTZDV     : Summer time rules (variable dates)

System Variables

1.     SY-TZONE          Date and time, time difference from Greenwich Mean Time.

2.     SY-DATUM     Date and time, current (application server) date.

3.     SY-UZEIT          Date and time, current application server time.

4.     SY-ZONLO     Date and time, time zone of user.

5.     SY-DATLO          Date and time, local date of user.

6.     SY-TIMLO          Date and time, local time for user.

Time Stamp Conversion


                     TIME ZONE tz

           INTO DATE d

                                      TIME t .

             CONVERT DATE d

                                TIME t

         INTO TIME STAMP tst

                  TIME ZONE tz.

The time stamp tst is always UTC time while d and t are always based on the time zone tz.The system always converts using the difference between the timezone tz and UTC time.

This implies that if you want to convert between non-UTC time zones then you can use the above statements in conjunction, First convert date & time in time zone 1 into UTC time stamp and then convert the UTC time stamp into date & time in time zone 2.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Hello Himanshu Gupta,

      The information was very useful for me but in my case I want to convert the Date and Time from server location time to order created Plant TimeZone. Do you have any ideas on this type of requirement.

      Appreciate your help.