Calculate Days, Weeks, Months and Year Between Two Dates in ABAP

3 December 2014
October 24, 2017

Now, we will show you tips how to calculate days, weeks, months and year with use function module HR_99S_INTERVAL_BETWEEN_DATES. With that function module you can easily calculate all you need. here we show the example code and the output will be generated from this program.

Output will display as below
DATA : lv_begda TYPE dats, lv_endda TYPE dats, lv_days TYPE i, lv_weeks TYPE i, lv_years TYPE i, lv_months TYPE i, lv_dmonths TYPE i, lt_months TYPE p99sg_month_tab, ls_months TYPE p99sg_month_tab_row . lv_begda = '19901007'. lv_endda = sy-datum. CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES' EXPORTING begda = lv_begda endda = lv_endda * TAB_MODE = ' ' IMPORTING days = lv_days c_weeks = lv_weeks c_months = lv_months c_years = lv_years * WEEKS = * MONTHS = * YEARS = d_months = lv_dmonths month_tab = lt_months. WRITE : 'Days = ' , lv_days , /. WRITE : 'Weeks = ' , lv_weeks , /. WRITE : 'Months = ' , lv_months , /. WRITE : 'Years = ', lv_years , /. WRITE : 'D Months = ' , lv_dmonths , /. WRITE : 'Month' , 'Year' , 'Begda' , 'Endda'. LOOP AT lt_months INTO ls_months . WRITE : ls_months-month , ls_months-year , ls_months-begda , ls_months-endda , /. ENDLOOP.

Tags:

Related Post