Add day/month/year to a date in ABAP

Add day/month/year to a date in ABAP

Add days to date

You can simply add integer value if your variable is typed DATUM.


  DATA : lw_date  TYPE  sy-datum.
  lw_date = '20170927'.
  lw_processed_date = lw_date + 5.
* ==> lw_processed_date = 20171002

Add days/month/year to date

You can use function ADD_TIME_TO_DATE :


DATA : lw_date            TYPE  sy-datum,
       lw_processed_date  TYPE  sy-datum,
       lw_iprkz           LIKE  mara-iprkz.

  lw_iprkz = 'D'. " D = Days M = Months Y = Years
  lw_date = '20170927'.

CALL FUNCTION 'ADD_TIME_TO_DATE'
  EXPORTING
    i_idate  = lw_date " Your Original Date Here
    i_time   = 5 " No.of Days or Months or Years you want to add to Given date
    i_iprkz  = lw_iprkz " Indicator - D = Days M = Months Y = Years
*   I_RDMHD   =
  IMPORTING
    o_idate  = lw_processed_date.   " Processed Date

* ==> lw_processed_date = 20171002

or use function RP_CALC_DATE_IN_INTERVAL :


  lw_date = '20170927'.

  CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
    EXPORTING
      date      = lw_date
      days      = 5
      months    = 0
      signum    = '+'    " Signum : "+" or "-" to add or remove
      years     = 0
    IMPORTING
      calc_date = lw_processed_date.

* ==> lw_processed_date = 20171002

Check also recent post : Manipulate dates in worked days

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

1 Comment so far

NoysisNuambPosted on5:28 pm - May 13, 2021

very nice blog

Leave a Reply