Hello,
I want to calculate in Powerpivot the workingtime between 2 fields.
Workdays have starttime at 08:00 uur and an endtime at 17:30
Did not attempt this in powerpivot but rather took to it with an older fashioned time formatting and text formula strategy that tests the mind but does get you the right answer.
| | | | | | | | | Working hours | | |
| | | | | | 8:00 | 17:30 | | 9:30 | 0.50 | |
Day of the week | Date & Time in custom format | Convert to Number format | Truncate fractions of a day | Time value | After start | Before finish | Fractions of hours | | | | |
Tuesday | 15/04/2014 16:00 | 41744.67 | 41744.00 | | 16:00 | 8:00 | 1:30 | | | | |
Monday | 21/04/2014 9:00 | 41750.38 | 41750.00 | | 9:00 | 1:00 | 8:30 | | | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
Sunday | 1 | Sunday | 0 | Networking day | | | | | | | |
Monday | 2 | Monday | 1 | 5 | | Hours in part days | | | | | |
Tuesday | 3 | Tuesday | 1.5 | | | | | | | | |
Wednesday | 4 | Wednesday | 9.5 | | | | | | | | |
Thursday | 5 | Thursday | 9.5 | | | | | | | | |
Friday | 6 | Friday | 9.5 | | | | | | | | |
Saturday | 7 | Saturday | 0 | | | | | | | | |
| | | 31 | | | | | | | | |
| | | | | | | | | | | |
| | | | Hours in whole working days between dates | | | | | | | |
| | | | 28.5 | | | | | | | |
| | | | | | | | | | | |
| | | | Hours in part days (first and last day) | | | Numerical value in hours | | | | |
| | | | 2:30 | | 2 | 0.50 | | 2.50 | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
| | | | Whole hours calculation | | | | 2.50 | | | |
| | | The answer | 31.00 | | | | | | | |
<colgroup><col><col><col><col><col><col span="7"></colgroup><tbody>
</tbody>
Based on the following formulas
| | | | | | | | | Working hours | | |
| | | | | | 0.333333333333333 | 0.729166666666667 | | =H2-G2 | =MINUTE(J2)/60 | |
Day of the week | Date & Time in custom format | Convert to Number format | Truncate fractions of a day | | Time value | After start | Before finish | Fractions of hours | | | |
=TEXT(D4,"dddd") | 41744.6666666667 | =B4 | =TRUNC(C4) | | =C4-D4 | =$F4-G$2 | =H$2-$F4 | | | | |
=TEXT(D5,"dddd") | 41750.375 | =B5 | =TRUNC(C5) | | =C5-D5 | =$F5-G$2 | =H$2-$F5 | | | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
Sunday | 1 | =A8 | 0 | Networking day | | | | | | | |
Monday | 2 | =A9 | 1 | =NETWORKDAYS(D4,D5) | | Hours in part days | | | | | |
Tuesday | 3 | =A10 | 1.5 | | | | | | | | |
Wednesday | 4 | =A11 | 9.5 | | | | | | | | |
Thursday | 5 | =A12 | 9.5 | | | | | | | | |
Friday | 6 | =A13 | 9.5 | | | | | | | | |
Saturday | 7 | =A14 | 0 | | | | | | | | |
| | | =SUM(D8:D14) | | | | | | | | |
| | | | | | | | | | | |
| | | | Hours in whole working days between dates | | | | | | | |
| | | | =(E9-2)*9.5 | | | | | | | |
| | | | | | | | | | | |
| | | | Hours in part days (first and last day) | | | | Numerical value in hours | | | |
| | | | =H4+G5 | | =HOUR(E21) | =MINUTE(E21)/60 | | =G21+H21 | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
| | | | | | | | | | | |
| | | | Whole hours calculation | | | | | =J21+F11 | | |
| | | The answer | =E18+J25 | | | | | | | |
<colgroup><col><col><col><col><col><col span="7"></colgroup><tbody>
</tbody>
Not what you wanted but well it works
Good luck