Working out how long a shift lasted seems like the simplest math there is — until the shift crosses midnight, and suddenly straightforward subtraction gives you a nonsensical negative number.
Why Overnight Shifts Break Simple Subtraction
A 24-hour clock resets to 00:00 at midnight, which means a shift starting at 10 PM (22:00) and ending at 6 AM (06:00 the next day) has an end time that's numerically smaller than its start time. Subtracting directly — 6:00 minus 22:00 — produces a negative duration, which is obviously wrong. The fix is to detect this case and add 24 hours to the end time before subtracting, which correctly accounts for the fact that the end time actually falls on the following calendar day.
Why Timesheets Use Decimal Hours
Payroll math multiplies hours worked by an hourly rate, and that calculation only works cleanly in decimal form. 7 hours and 30 minutes written as "7:30" isn't actually the number 7.30 — the minutes portion isn't a base-100 fraction, so multiplying 7.30 by an hourly rate would give a wrong answer. Converting properly to 7.5 decimal hours first makes the multiplication straightforward and accurate, which is exactly why payroll systems and timesheets standardize on decimal hours rather than the hours:minutes format people naturally think in.
Converting Minutes to a Decimal Fraction
Since an hour contains 60 minutes, converting minutes to a decimal fraction just means dividing by 60. 30 minutes becomes 30 ÷ 60 = 0.5, 15 minutes becomes 15 ÷ 60 = 0.25, and 45 minutes becomes 45 ÷ 60 = 0.75. This is why decimal-hour values so often land on familiar-looking numbers like 0.25, 0.5, and 0.75 — they correspond to quarters, halves, and three-quarters of an hour, which are also the most common real-world shift-length increments.
Calculate a Duration Instantly
Enter a start and end time, including overnight spans, into the free Time Duration Calculator to get the exact duration in hours, minutes, and decimal hours.
FAQ
Why does simple time subtraction break for an overnight shift? If a shift starts at 10 PM and ends at 6 AM, naively subtracting the start time from the end time produces a negative number, since 6:00 is numerically smaller than 22:00 on a 24-hour clock. The calculation has to detect that the end time is "earlier" than the start time and add 24 hours to the end time before subtracting, to correctly account for the shift crossing midnight into the next day.
Why do timesheets use decimal hours instead of hours and minutes? Payroll calculations multiply hours worked by an hourly rate, and that math is far simpler with decimal hours than with hours-and-minutes format. 7 hours and 30 minutes becomes 7.5 in decimal form, which multiplies cleanly against an hourly rate, whereas the minutes portion of "7:30" isn't actually a base-100 fraction and would produce an incorrect result if multiplied directly.
How do you convert minutes into a decimal fraction of an hour? Divide the minutes by 60, since an hour contains 60 minutes. 30 minutes becomes 30/60 = 0.5, 15 minutes becomes 15/60 = 0.25, and 45 minutes becomes 45/60 = 0.75. This is why decimal-hour values often look like familiar fractions — quarters, halves, and thirds of an hour convert to clean decimal values.