How To: Difference Between Two Times
Subtract the start from the end to get the difference as a fraction of a day, then multiply by 24 for hours. If the end is on the next day (a night shift), the subtraction goes negative: add 1 day with MOD(end - start, 1).
Times here are entered as fractions of a day: 8:30 is 8.5 / 24.
Exampleexcel
Quick check
A shift runs from 22:00 to 06:00. Which formula handles the midnight crossing?
Your turn: write the code
Show the hours worked in C2 from the start in A2 and the end in B2 (finish minus start, times 24).
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.