Days_between_two_dates. How to find difference between dates in ABAP SAP?

Using the function module DAYS_BETWEEN_TWO_DATES we can quickly get the result as the difference between dates in days. You can count the days until the end of the payment term or calculate the number of days until the end of the contract and much more.

Function module DAYS_BETWEEN_TWO_DATES call example:

" for example sy-datum = '20230815'.
" and lv_date = '20230810'.

  CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
    EXPORTING
      i_datum_bis = sy-datum
      i_datum_von = lv_date
    IMPORTING
      e_tage      = lv_days
    EXCEPTIONS
      OTHERS      = 0.

" as a result lv_days = 5

Main settings:

  • i_datum_bis – date from which to subtract. (i_datum_bis = 21.04.2022)
  • i_datum_von – date to be subtracted. (i_datum_bis = 11.04.2022)
  • e_tage – result, difference of days. (e_tage = 10).

All function method DAYS_BETWEEN_TWO_DATES signature with types:

FM DAYS_BETWEEN_TWO_DATES

In what task did you use this FM? Do you know an alternative to this Functional module? Write in the comments!

Leave a Reply