cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in months

former_member189410
Participant
0 Kudos

Hi,

can anyone tell me any function module which will return the no of months between two dates like

if i enter .

12.12.2008 - 08.08.2009

it shud return 9 as no of months .

if 12.02.2007 - 05.05.2007 it shud return '4'.

thnx

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

try this code



DATA: lv_m(10) TYPE C.

CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
  EXPORTING
    i_datum_bis         = '20070505'
    i_datum_von         = '20070212'
   I_KZ_INCL_BIS       = 'X' "takes the to date into consideration
 IMPORTING
   E_MONATE            = lv_m.

"the result here is 3... I guess 3 full months...

otherwise get the number of days btw two dates and calculate according to your req:


CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
          EXPORTING
            I_DATUM_BIS                   = l_END_DAY
            I_DATUM_VON                   = l_START_DAY
            I_KZ_INCL_BIS                 = '1'
            I_STGMETH                     = '2'
          IMPORTING
            E_TAGE                        = l_DAYS.

hope this helps,

Olivier.

Former Member
0 Kudos

Hi

Check this previous thread which speaks on same

https://forums.sdn.sap.com/click.jspa?searchID=2271431&messageID=3066260

hope this solves ur problem

Regards

Kiran