Convert Date <-> Timestamp in ABAP/4

Date to Timestamp

Example

*&---------------------------------------------------------------------*
*&    Form convert_date_to_timestamp
*&---------------------------------------------------------------------*
form convert_date_to_timestamp using par_date
                                   par_time
                                   par_time_zone
                             changing par_timestamp.
clear par_timestamp.
CONVERT DATE par_date TIME par_time INTO
        TIME STAMP par_timestamp TIME ZONE par_time_zone.
endform.                  " convert_date_to_timestamp

Timestamp to Date

Example


*&---------------------------------------------------------------------*
*&    Form convert_timestamp_to_date
*&---------------------------------------------------------------------*

form convert_timestamp_to_date using par_timestamp
                                   par_time_zone
                             changing par_date
                                      par_time.
data: lc_timestamp type timestamp.
clear: par_date, par_time, lc_timestamp.
lc_timestamp = par_timestamp.
CONVERT TIME STAMP lc_timestamp TIME ZONE par_time_zone INTO
      DATE par_date TIME par_time.
endform.                  " convert_timestamp_to_date

Post new comment