ABAP日期和时间运算
"日期运算是以天为单位,时间运算以秒为单位。
DATA:date1 TYPE d.
"服务器当前日期
date1 = sy-datum.
WRITE: / date1 . "20190117
"当前月的第一天,采用字符偏移操作
date1+6(2) = '01'. " = first day of this month
WRITE: / date1 . "20190101
"上月最后一天
date1 = date1 - 1. " = last day of last month
WRITE: / date1 . "20181231
DATA: time1 TYPE t.
"服务器当前时间
time1 = sy-uzeit.
WRITE: / time1. "091655
"当前时间修改为00:00:00
time1 = '000000'. "000000
WRITE: / time1.
"增加一个小时
time1 = time1 + 60 * 60 * 1. "010000
WRITE: / time1.
"重置小时数为2小时
time1+0(2) = '02'.
WRITE: / time1. "020000