2014 Oct 23 2:38 PM
Hi guys,
I am looking for a standard function module for the following task:
I need to calculate the time difference between two timestamps. So far so easy.
The problem is, that I need to take working hours into account. So instead of just calculating the time difference I need the time difference in working hours.
Say working hours are from 9 to 5 and the first timestamp would be 10 am today and the second would be 10 am tomorrow, than the result I am looking for is not 24 hours but instead 8 hours, which would be the total of working hours between those two timestamps.
Any hints are very much appreciated.
Many thanks in advance,
Tobias
Hi guys,
I am looking for a standard function module for the following task:
I need to calculate the time difference between two timestamps. So far so easy.
The problem is, that I need to take working hours into account. So instead of just calculating the time difference I need the time difference in working hours.
Say working hours are from 9 to 5 and the first timestamp would be 10 am today and the second would be 10 am tomorrow, than the result I am looking for is not 24 hours but instead 8 hours, which would be the total of working hours between those two timestamps.
Any hints are very much appreciated.
Many thanks in advance,
Tobias
2014 Oct 23 2:56 PM
Hi,
maybe just calculate the number of working day with the function ...convert...to...factorydate .. and just add the number of hour at the first day and the last day .. no ?
regards
Fred
2014 Oct 23 3:37 PM
Hi Tobias,
I don't have a code sample, but I guess the logic would be:
1. Check the dates between the start & end date of the timestamps:
1.a. If it's the same date (and your certain that the ending time stamp is within the working hours...):
Get the time difference. => the solution to your problem.
else continue with 2.
2.. If the dates are different (and end date > start date)
2.a. Get the time from starting timestamp till end of working day.
2.b. Get the no. of complete working days between the start & end.
You can this FM to accomplish this: RKE_SELECT_FACTDAYS_FOR_PERIOD
2.c. Get the time between start of working day till the ending time stamp.
=> The sum of 2.a, 2.b and 2.c is the solution to your problem.
Have fun!
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |