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: 

i want to add 2 months to the current date

Former Member
0 Kudos

actally i want to add 2 montsh fro teh current date.but i have to consider the month of february for the calculation and even the leap year.

so can u guys help me out .

waiting for the reply

thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Rajeev ,

Welcome to SDN.

Check this and execute the code.

This will cover the leap year also.

data: date like sy-datum,
      date1 like sy-datum.

date = sy-datum.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date            = date
    days            = 00       
    months          = 02     "no of months
   SIGNUM           = '+'  "months added
    years           = 00
 IMPORTING
   CALC_DATE       = date1. " new date


write:/ 'new date',  date1.

regards.

vijay

6 REPLIES 6

Former Member
0 Kudos

Hi Rajeev ,

Welcome to SDN.

Check this and execute the code.

This will cover the leap year also.

data: date like sy-datum,
      date1 like sy-datum.

date = sy-datum.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
  EXPORTING
    date            = date
    days            = 00       
    months          = 02     "no of months
   SIGNUM           = '+'  "months added
    years           = 00
 IMPORTING
   CALC_DATE       = date1. " new date


write:/ 'new date',  date1.

regards.

vijay

0 Kudos

use Fm -

SG_PS_ADD_MONTH_TO_DATE

Former Member
0 Kudos
data: ws_date type sy-datum,
ws_new_date type sy-datum.

ws_date = '20060101'.

CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = '2'
olddate = ws_date
IMPORTING
newdate = ws_new_date.

write: / ws_new_date

Former Member
0 Kudos

Hi,

Use the FM SG_PS_ADD_MONTH_TO_DATE.

It considers leap years also

Regards

Arun

anversha_s
Active Contributor
0 Kudos

hi,

chk this.

data : wa_date type sy-datum.
 
call function 'RP_CALC_DATE_IN_INTERVAL'
exporting
date = sy-datum
days = 0 
months = 2--------------------> give ur required month
years = 0
signum = '+'
importing
calc_date = wa_date.
 
write 😕 wa_date. -> new minised date
 
Note
signum = '+' " 
signum = '-' "

Regards

Anver

Former Member
0 Kudos

thanks a lot for answering the question.