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: 

Calculation on Date

Former Member
0 Kudos

Hi all,

I have to add 120 days into the system date i.e.sy-datum and then subtract 5 days from the added one

How to do this...

Plz reply soon....

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos

hi Rahul,

data : lv_date type sy-datum.

lv_date = sy-datum + 115.

hope this helps

ec

10 REPLIES 10

JozsefSzikszai
Active Contributor
0 Kudos

hi Rahul,

data : lv_date type sy-datum.

lv_date = sy-datum + 115.

hope this helps

ec

Former Member
0 Kudos

hi

u can subtract like normal mathematical operation.just store outpur in the date type variable.

regards

vivek

Former Member
0 Kudos

FM CALCULATE_DATE will solve ur query

Reward points if it helps

Former Member
0 Kudos

data: zday type d.

zday = 'sy-datum'.

zday = zday + 120.

and thrn

zday=zday-5,

Former Member
0 Kudos

sy-datum stores the value in this format YYYYMMDD .

use this code and it will work automatically for you, The system handles the no of days in the month.

data: wf_datu like sy-datum.

wf_datu = sy-datum.

wf_datu = wf_datu - 120 + 5.

write: wf_datu.

thanks,

Amit

Former Member
0 Kudos

data : v_date1 like sy-datum , v_date2 like sy-datum.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = sy-datum

days = 120

months = 0

SIGNUM = '+'

years = 0

IMPORTING

calc_date = v_date1.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

date = v_date1

days = 5

months = 0

SIGNUM = '-'

years = 0

IMPORTING

calc_date = v_date2.

Former Member
0 Kudos

DATA: d LIKE sy-datum,

dd LIKE sy-datum.

START-OF-SELECTION.

d = sy-datum.

dd = d + 120.

ddd = dd - 5.

WRITE:/ 'd =', d.

WRITE:/ 'dd =', dd.

WRITE:/ 'ddd =', ddd.

Former Member
0 Kudos

Hi,

use the FM:

<b>RP_CALC_DATE_IN_INTERNAL</b> – add/subtract year/month/days from a date

Hope this helps.

Reward if helpful.

Regards,

Sipra

Former Member
0 Kudos

hi! Rahul

get the day, month, year separately and then add 120 to day

date1 = sy-datum

day = date1+6(2).

month = date1+4(2) .

year = date+0(4).

add_date1 = day + 120.

concatenate year month add_date1 to add_date. " as per sap default format

final_date1 = add_date1 - 5.

concatenate year moth final_date1 to final_date.

why you have add and subtract instead you can directly add by 115.

Reward me if its useful

Regards,

Nagulan

Former Member
0 Kudos

Hi Rahul,

You can use this function:

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting

date = sy-datum

days = 25 -


> give the no of days to be added

months = 3 -


> give the no of months to be added

years = 0 -


> give the no of years to be added

signum = '+'

importing

calc_date = wa_date.

Reward useful answers.