Skip to Content
author's profile photo Former Member
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...

Plz reply soon....

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

10 Answers

  • Best Answer
    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 18, 2007 at 09:23 AM

    FM CALCULATE_DATE will solve ur query

    Reward points if it helps

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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.

    Reward if helpful.

    Regards,

    Sipra

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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).

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    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.

    Reward useful answers.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.