Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

calculating months to a date

kishorepallapothula
Participant
0 Kudos

Hi SAP gurus,

How to calculate months to a date.

I have a scenario to minus 20 months to sy-datum.

for example:

24.09.2008 - 20 (months) = 24.01.2007

i have to get the date 24.01.2007.

I have to count the days back to the system date. Is there any function module for this. please let me know.

<removed_by_moderator>

kishore

Edited by: Julius Bussche on Sep 24, 2008 10:53 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Please chech the FM "MONTH_PLUS_DETERMINE".

Hope this will be useful.

Regards,

P.S.Chitra

6 REPLIES 6

Former Member
0 Kudos

Hi,

Please chech the FM "MONTH_PLUS_DETERMINE".

Hope this will be useful.

Regards,

P.S.Chitra

JozsefSzikszai
Active Contributor
0 Kudos

hi,

you can use FM CALCULATE_DATE, importing parameters MONTHS has to be -20 (minus 20)

hope this helps

ec

Former Member
0 Kudos

hi,

use

do n times.
HRAR_SUBTRACT_MONTH_TO_DATE
enddo.

Here n = 20 for your case as the FM reduce 1 month from the given date.

Regards,

Anirban

Former Member
0 Kudos

Hi kishore,

Use the Fm 'MONTH_PLUS_DETERMINE'

data: new_date type d.

CALL FUNCTION 'MONTH_PLUS_DETERMINE'
  EXPORTING
    months         = -12       " Negative to subtract from old date, positive to add
    olddate         = sy-datum
 IMPORTING
   NEWDATE     = new_date.

write: / new_date.

Good luck,

Bhumika

Former Member
0 Kudos

Hi Kishore,

Try this FM:

RP_CALC_DATE_IN_INTERVAL

Add/subtract years/months/days from a date

Or as others have also said do it with the FM:

MONTH_PLUS_DETERMINE

Add or subtract months from a date. To subtract a month, enter a negative value for the 'months' parameter.

data: new_date type d.

CALL FUNCTION 'MONTH_PLUS_DETERMINE'
  EXPORTING
    months        = -5       " Negative to subtract from old date, positive to add
    olddate       = sy-datum
 IMPORTING
   NEWDATE       = new_date.

write: / new_date.

With luck,

Pritam.

kishorepallapothula
Participant
0 Kudos

Hi ,

I find the solution for this.

Function module is CCM_GO_BACK_MONTHS.

Thanks for your co-operation.

i awarded all of you with points.

Kishore