How to Calculate Hours Between Two Times

Subtract the start time from the end time, and add a day if the end is earlier so overnight shifts come out right. Includes decimal hours for timesheets.

Updated 4 min read By CodingEagles
Free tool Time Duration Calculator Hours and minutes between two times, overnight-aware. Open tool

To calculate the hours between two times, subtract the start time from the end time. If the end time is earlier than the start, the period ran past midnight, so add 24 hours before subtracting. The time duration calculator does this for you and shows the result in hours and minutes, in total minutes, and in decimal hours.

The basic subtraction

For a span within a single day, convert both times to a count from midnight and subtract. A shift from 09:00 to 17:30 is eight and a half hours, because 17:30 is 8 hours and 30 minutes after 09:00. Working in minutes first and then converting back to hours and minutes avoids slips with the 60-minute boundary.

Handling overnight shifts

The catch is a period that crosses midnight, where the end time on the clock looks earlier than the start. A shift from 22:00 to 06:00 is not negative, it is eight hours. The fix is to add a full day, 24 hours, to the end time before subtracting. The time duration calculator assumes any end time earlier than the start belongs to the next day, so overnight shifts come out right without extra steps.

Getting decimal hours

Hours and minutes are easy to read, but timesheets and invoices often want a single decimal number. To convert, divide the minutes by 60 and add them to the hours. So 8 hours 30 minutes becomes 8.5, and 1 hour 15 minutes becomes 1.25. This decimal figure multiplies straight by an hourly rate. The calculator shows it next to the hours and minutes.

Where this comes up

A clean hours-between figure matters for a few everyday tasks:

  • Pay and timesheets, counting hours worked between clock-in and clock-out, including overnight shifts.
  • Billing, turning a session into decimal hours for an invoice.
  • Planning, measuring how long something took between a start and an end time.

Enter a start and end time in the time duration calculator to get the hours, minutes and decimal total at once. For spans across days rather than within one, see how many days between two dates.

Frequently asked questions

How do I calculate the hours between two times?
Subtract the start time from the end time. If the end time is earlier than the start, add 24 hours so the span crosses midnight correctly. The time duration calculator does this and also shows the total in minutes and in decimal hours.
How do I work out an overnight shift?
When the clock-out is earlier in the day than the clock-in, the shift ran past midnight. Add 24 hours before subtracting, so 22:00 to 06:00 comes out as 8 hours rather than a negative number. The calculator handles this automatically.
What are decimal hours?
Decimal hours express a duration as one number, so ninety minutes is 1.5 hours and fifteen minutes is 0.25 hours. Timesheets and billing often use this format because it multiplies cleanly by an hourly rate.

Ready to try it?

Hours and minutes between two times, overnight-aware. Free, in-browser, and 100% private. Your data never leaves your device.

Open the Time Duration Calculator