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: 

Function modeul to calculate time in hours

Former Member
0 Kudos

I have 4 fields: starte date, start time, end date and end time.

Is there a standard function or how do I write a function to calulate the time? Input field should be starte date, start time, end date and end time. Ouput should be time difference in hours.

Thanks for your help in advance.

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

Please search in SCN before posting basic Questions !!!!

8 REPLIES 8

kesavadas_thekkillath
Active Contributor
0 Kudos

Please search in SCN before posting basic Questions !!!!

0 Kudos

It's actually not that basic to calculate time differences across different dates.

Rob

0 Kudos

Hi Rob ,

actually it should be Frequently asked Question

Hi Amy,

use this


PARAMETERS:p_stime TYPE sy-uzeit,
           p_etime TYPE sy-uzeit,
           p_sdate TYPE sy-datum,
           p_edate TYPE sy-datum.
 
DATA: v_hours TYPE p DECIMALS 2.
 
v_hours = ( ( p_edate - p_sdate ) * 24
+ ( p_etime - p_stime ) / 3600 ).

or use

SD_CALC_DURATION_FROM_DATETIME

Edited by: Keshu Thekkillam on Oct 7, 2009 10:41 PM

Edited by: Keshu Thekkillam on Oct 7, 2009 10:47 PM

0 Kudos

>

> actually it should be Frequently asked Question

Guess you're right. I don't normally look too closely at time questions.

Should I unassign the points?

Rob

Edited by: Rob Burbank on Oct 7, 2009 1:40 PM

0 Kudos

Your wish

0 Kudos

Thank you all for your help. I've given points to the helpful answers.

0 Kudos

Thanks amy, but next time remember that just about every question possible has been asked and answered before. If you search before posting, you are very likely to find an answer.

Rob

former_member723628
Active Participant
0 Kudos

Amy,

You can use FM CCU_TIMESTAMP_DIFFERENCE. It takes Timestamp1 and Timestamp2 as parameters and returns time difference in seconds.

Gajendra