Former Member

# Calculation on Date

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...

10|10000 characters needed characters exceeded

### Related questions

Posted on Oct 18, 2007 at 09:22 AM

hi Rahul,

data : lv_date type sy-datum.

lv_date = sy-datum + 115.

hope this helps

ec

10|10000 characters needed characters exceeded
• Former Member
Posted on Oct 18, 2007 at 09:23 AM

hi

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

regards

vivek

10|10000 characters needed characters exceeded
• Former Member
Posted on Oct 18, 2007 at 09:23 AM

FM CALCULATE_DATE will solve ur query

Reward points if it helps

10|10000 characters needed characters exceeded
• Former Member
Posted on Oct 18, 2007 at 09:23 AM

data: zday type d.

zday = 'sy-datum'.

zday = zday + 120.

and thrn

zday=zday-5,

10|10000 characters needed characters exceeded
• Former Member
Posted on Oct 18, 2007 at 09:23 AM

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

10|10000 characters needed characters exceeded
• Former Member
Posted on Oct 18, 2007 at 09:24 AM

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.

10|10000 characters needed characters exceeded
• Former Member
Posted on Oct 18, 2007 at 09:25 AM

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.

10|10000 characters needed characters exceeded
• Former Member
Posted on Oct 18, 2007 at 09:26 AM

Hi,

use the FM:

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

Hope this helps.

Regards,

Sipra

10|10000 characters needed characters exceeded
• Former Member
Posted on Oct 18, 2007 at 09:27 AM

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).

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

concatenate year moth final_date1 to final_date.

Reward me if its useful

Regards,

Nagulan

10|10000 characters needed characters exceeded
• Former Member
Posted on Oct 18, 2007 at 09:30 AM

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.