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: 

Date calculation

Former Member
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

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

Former Member
0 Kudos

Check fm RP_CALC_DATE_IN_INTERVAL

I find it very useful.

Cheers.

Former Member
0 Kudos

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

former_member182371
Active Contributor
0 Kudos

To solve the problem use function module

DATE_CONV_EXT_TO_INT

Hope it works.

let me know if it´s the case.

0 Kudos

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