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: 

How to sum 20 years to a specific date?

Former Member
0 Kudos

Is there any FM to do it ?

6 REPLIES 6

LucianoBentiveg
Active Contributor
0 Kudos

Nop, but you can use RE_ADD_MONTH_TO_DATE, and add 240 months.

Regards.

Former Member
0 Kudos

u have date....say 20061222 which is by default in sap format....now

V1 = date+0(4).

V2 = date+4(2).

V3 = date+6(2).

V1 = V1 + 20.

Concatenate V1 V2 V3 into date.

Former Member
0 Kudos

you can use this Fm

data: v_date like sy-datum,
      v_datenew like sy-datum.

 v_date = sy-datum.


CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date            = v_date
    days            = 00
    months          = 00
   SIGNUM           = '+' "sum 
    years           = 20  "number of years
 IMPORTING  
   CALC_DATE       = v_datenew.


write:/'Current date',  v_date,
        'new date   ', v_datenew.

hope this helps

regards,

vijay

Former Member
0 Kudos

Hi Please use the FM

<b>RP_CALC_DATE_IN_INTERVAL</b>

e.g

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

DATE = date

DAYS = 0

MONTHS = 0

SIGNUM = '+'

YEARS = 20

IMPORTING

CALC_DATE = L_DDATE

EXCEPTIONS

OTHERS = 1.

Former Member
0 Kudos

Hi maria,

1. If we simply want to add years, (and not months),

then we can do directly using offset for YYYY (in yyyymmdd)

2.

20.12.2006 -


> 20.12.2026

3. Just copy paste

4.

REPORT abc.

data : date1 like sy-datum .

data : date2 like sy-datum.

date1 = sy-datum.

date2 = date1.

date2(4) = date1(4) + 20.

write 😕 date1.

write 😕 date2.

regards,

amit m.

Former Member
0 Kudos

Hi, you can also use this function :

CALL FUNCTION 'SALP_CALC_DATE'

EXPORTING

IN_RECTYPE = 'Y'

IN_NBR_DWXMQY = 20

IN_DATE = sy-datum

IMPORTING

OUT_DATE = l_date

EXCEPTIONS

OTHERS = 0.

Regards,

Mathieu