Skip to Content
0
Former Member
Sep 26, 2008 at 12:01 AM

Method help !!

125 Views

hi experts,

Can anyone help in writing the method for the below requirement.

Ex:

OldDate: 03/10/1992

Current Date:09/24/2008

Calculation : (difference between the two dates) / 365 = 6042 / 365 = 16.55 (rounded to the second decimal place)

I tried with the below code. Not sure if it is right.

METHOD NoOfDays.

DATA: employerServiceDate TYPE sy-datum,

noofdays TYPE i,

l_year TYPE char4,

l_mm TYPE char2,

l_dd TYPE char2,

l_diff_days TYPE d.

CLEAR :l_year,l_mm,l_dd,values,l_diff_days,employerServiceDate.

l_mm = employerServiceDate(2).

l_dd = employerServiceDate+3(2).

l_year = employerServiceDate+6(4).

CONCATENATE l_year l_mm l_dd INTO employerServiceDate.

l_diff_days = (sy-datum - employerServiceDate)/365.

values = l_diff_days.

ENDMETHOD.

Thanks

Ramani