Application Development and Automation 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: 
Read only

Date and Time Calculation

Former Member
0 Likes
1,339

Dear all.

I need a function that receives a Date / Time and another Date and calculates the the sum of those values.

Best Regards,

Thanks In advanced.

PMR

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,255

Hai Rodrigues,

The program which i gave you works out for you,i suppose.

Just check out the earlier replies..

Regards,

Srikanth.

Hai Rodrigues,

The program which i gave you works out for you,i suppose.

Just check out the earlier replies..

Regards,

Srikanth.

8 REPLIES 8
Read only

Former Member
0 Likes
1,255

Sum of two dates makes no sense.

Is it a sum of a date and number of days?

Then do like this.

v_new_date = v_date + no_of_days.

If you still want the sum of two dates,

just add them up and see what happens.

v_new_date = v_date1 + v_date2.

Regards,

Ravi

Read only

Former Member
0 Likes
1,255

Hi Pedro,

PLease try out this function module...

RE_ADD_MONTH_TO_DATE

Please reward points if the answer was useful.

Regards,

Kunal

Read only

Former Member
0 Likes
1,255

Hai Rodrigues,

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.

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

Regards,

Srikanth.

Read only

Former Member
0 Likes
1,255

Dear All.

Update my Inquiry.

I need a function that receives a Date / Time and another time and calculates the the sum of those values.

Best Regards.

Thanks in Advanced

PMR

Read only

Former Member
0 Likes
1,255

HI,

Will ADD_TIME_TO_DATE help?

Regards,

Gayathri

Read only

Former Member
0 Likes
1,255

Dear all.

New update, Thanks for all helpfull replay's.

I need to pass the following Informations:

Import:

Date_1 (MM.DD.AAAA)

TIME_1 (HH:MM:SS)

Durations (HH:MM:SS)

Export:

Date_Result (MM.DD.AAAA)

Time_Result (HH:MM:SS)

The result off this funtions (If exist in the Standard) should be exemple:

Date_1 18.04.2006

Time_1 23:45:56

Durations 02:00:00

The result of the function must be

Date_Result 19.04.2006

Time_result 01:45:56.

Read only

Former Member
0 Likes
1,256

Hai Rodrigues,

The program which i gave you works out for you,i suppose.

Just check out the earlier replies..

Regards,

Srikanth.

Read only

0 Likes
1,255

Hi Rodrigues,

Here is the Function Module that satisfies your requirement completely.

It is C14B_ADD_TIME.

Just check this code and try to give your own values.

data: a type sy-uzeit,

b type sy-datum,

c type sy-uzeit,

endtime type sy-uzeit,

enddate type sy-datum.

a = sy-uzeit.

b = sy-datum.

c = sy-uzeit.

CALL FUNCTION 'C14B_ADD_TIME'

EXPORTING

i_starttime = a

i_startdate = b

i_addtime = c

IMPORTING

E_ENDTIME = endtime

E_ENDDATE = enddate

.

write : endtime, enddate, a , c.

This will work.

Regards,

SP.