Guides / How to Calculate Hours Worked Between Two Times Guide

How to Calculate Hours Worked Between Two Times

The maths behind a simple shift, and the one rule that handles overnight shifts.

The most basic question in timekeeping is also the one people get wrong most often on overnight shifts: how many hours passed between a start time and an end time? For a same-day shift, it's simple subtraction. For a shift that crosses midnight, there's one extra step.

Same-day shifts

Convert both times to 24-hour minutes-since-midnight, then subtract the start from the end.

  • 9:00 AM = 9 × 60 = 540 minutes
  • 5:00 PM = 17:00 = 17 × 60 = 1,020 minutes
  • 1,020 − 540 = 480 minutes = 8 hours

Overnight shifts

When the end time is earlier in the clock than the start time — like 9:00 PM to 5:00 AM — a plain subtraction gives a negative number, which is obviously wrong. The fix: if the result is negative (or zero), add 24 hours (1,440 minutes) to it, since the shift actually ended the next calendar day.

  • 9:00 PM = 21:00 = 1,260 minutes
  • 5:00 AM = 5:00 = 300 minutes
  • 300 − 1,260 = −960 minutes (negative, so add 1,440)
  • −960 + 1,440 = 480 minutes = 8 hours

Notice both examples land on exactly 8 hours — that's not a coincidence, it's the same shift length, just shifted by 12 hours into the night. Getting the overnight rule right means a night-shift worker's hours are just as accurate as a day-shift worker's.

A trickier overnight example

An overnight shift runs from 11:30 PM to 6:15 AM.

  • 11:30 PM = 23:30 = 1,410 minutes
  • 6:15 AM = 6:15 = 375 minutes
  • 375 − 1,410 = −1,035 (negative, add 1,440)
  • −1,035 + 1,440 = 405 minutes = 6 hours, 45 minutes remainder
  • Total: 6h 45m

The Hours Calculator applies this exact rule automatically, so you can check any shift — day or night — without doing the minutes maths by hand.

12-hour clock vs. 24-hour clock

Most of the confusion in this kind of maths comes from converting AM/PM times correctly. On a 24-hour clock, midnight is 00:00 and noon is 12:00 — there's no ambiguity. On a 12-hour clock, midnight is written as 12:00 AM and noon as 12:00 PM, which trips people up because the "12" doesn't behave like every other hour does when switching between AM and PM. The safest approach for calculations is to convert everything to 24-hour time first: for AM hours, the 24-hour hour is the same number (except 12 AM, which becomes 00); for PM hours, add 12 to the 12-hour value (except 12 PM, which stays 12).

What if the start and end time are the same?

If the start time and end time are identical, the elapsed time is either 0 hours (nothing happened) or a full 24 hours (an entire day passed), depending on context. Most of the time this points to a data-entry mistake rather than an actual 24-hour shift, so it's worth double-checking the clock-in and clock-out values if you see this result.

Why this matters beyond payroll

Getting elapsed time right isn't only about pay. Scheduling software, break compliance, and even simple things like knowing when a shift actually ends all depend on the same start-to-end calculation. A scheduling tool that mishandles overnight shifts might show a night-shift worker's hours as negative or wildly wrong, which cascades into wrong weekly totals and wrong overtime calculations later. Getting this one calculation right at the source is what makes every calculation built on top of it (weekly totals, overtime, pay) trustworthy.

Common mistakes

  • Getting a negative number and not knowing what to do with it. A negative result on an overnight shift almost always means "add 24 hours," not "something is broken."
  • Mixing up noon and midnight in 12-hour time. 12:00 AM is midnight (start of day) and 12:00 PM is noon; confusing the two throws off every calculation that follows.
  • Forgetting a break. This guide covers the elapsed time only. If the shift includes a lunch, see our guide on subtracting a lunch break as well.
  • Assuming a same-day shift can't have a negative result. If a start time is accidentally entered as later than the true end time on a day shift, you'll get the same negative-number symptom as an overnight shift — check the raw times before assuming it's an overnight case.

Estimates only. Not legal, tax, or payroll advice.

Try it yourself