Date Operation in ABAP/4

The date variable in ABAP/4 have format "YYYYMMDD". If you want to get no. of year, month or day for the date, you can offset this variable.

Example


DATA: lv_date TYPE D VALUE sy-datum, "20050312
lv_year(4),
lv_month(2),
lv_day(2).

lv_year = lv_date(4). "2005
lv_month = lv_date+4(2). "03
lv_day = lv_date+6(2). "12

If you want to find next n day of the date, you can apply opration sign ’+’ to this point.

Example


DATA: lv_date TYPE D VALUE sy-datum,    "20050312
lv_next_date TYPE D.
lv_next_date = lv_date + 2. "lv_next_date = ’20050314’

If you want to find last n day of the date, you can apply opration sign ’-’ to this point.

Example


DATA: lv_date TYPE D VALUE sy-datum,    "20050312
lv_next_date TYPE D.
lv_next_date = lv_date - 2. "lv_next_date = ’20050310’
 

Thank you.

Thank you.

Post new comment