Skip to Content
author's profile photo Former Member
Former Member

Date calculation

Hello,

I want to calculate a new date (p.e. today + 3 months = 90 days)? I've tried to do this with the convert date and convert inverted-date, but the result was, that I ended with a date that was wrong (p.e. 43.04.2004).

Can someone help me?

Kind Regards,

S. Thomas

Add comment
10|10000 characters needed characters exceeded

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 03, 2004 at 05:43 PM

    Hi Sylvie.

    If you want to add 90 days.

    Just do t1 = sy-datum + 90.

    The system will automatically take care of the addition.

    But if you want to add 3 months, then I would say you put in your piece of code.

    a. Fetch the month component

    b. add 3 to month component

    c. if month component greater than 12 then month = month -12.

    d. year = year + 1.

    Pavan

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 04, 2004 at 01:33 PM

    Check fm RP_CALC_DATE_IN_INTERVAL

    I find it very useful.

    Cheers.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 05, 2004 at 04:19 AM

    Hi,

    You can even check this function modules, it works fine.

    Function Module Name:: ADD_TIME_TO_DATE

    Short Description :: Adds months/days/years to date.

    Entering a negative value will subtract from the date.

    Parameters ::

    Exporting:

    I_IDATE : Initial date

    I_TIME : Quantity to add

    I_IPRKZ : Unit of time(D:day, M:month, W:week, Y:year)

    Importing:

    O_IDATE : OUTPUT DATE.

    Message was edited by: Bharath Kumar B

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on May 05, 2004 at 10:01 PM

    To solve the problem use function module

    DATE_CONV_EXT_TO_INT

    Hope it works.

    let me know if it´s the case.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      The function module CALCULATE_DATE also adds/subtracts days and months to/from a date. The following website also demonstrates a number of ways to add days/months taking into account working and non working days if that is any use. http://www.sapdevelopment.co.uk/tips/date/datehome.htm

      CALL FUNCTION 'CALCULATE_DATE'

      EXPORTING

      • DAYS = '0'

      months = '01'

      start_date = p_date

      IMPORTING

      result_date = p_date.

      Message was edited by: Mart