Abap - Date Time manipulations

By xngo on February 21, 2019

REPORT  Z_DATE_TIME.
 
DATA: LV_DATE TYPE D,
      LV_TIME TYPE T,
      LV_DATE_TIME TYPE STRING.
 
LV_DATE = SY-DATUM.
LV_TIME = SY-UZEIT.
 
WRITE: / 'Current Date:', LV_DATE MM/DD/YYYY.
WRITE: /(60) LV_TIME USING EDIT MASK 'Current Time: __:__:__'.
 
* Put date and time into a string.
CONCATENATE LV_DATE(4) LV_DATE+4(2) LV_DATE+6(2) INTO LV_DATE_TIME SEPARATED BY '-'.
CONCATENATE LV_DATE_TIME '_' LV_TIME(2) '.' LV_TIME+2(2) '.' LV_TIME+4(2) INTO LV_DATE_TIME.
WRITE: / LV_DATE_TIME.

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.