How to Calculate Duration of Time

Whether you're tracking a work shift, a project, or the gap between two calendar dates, this guide walks through how to calculate duration of time step by step, including the formula, the manual method, and how to convert your result into decimal hours for payroll. If you'd rather skip the math entirely, our free time duration calculator handles all of this instantly.

Key Takeaways
  • Formula: end time minus start time equals duration. Add 24 hours before subtracting if the span crosses midnight.
  • Use a date-based method for spans longer than a day, since months don't all have the same number of days.
  • Convert to decimal hours for payroll by dividing the minutes by 60 and adding that to the whole hours.
  • Our calculator does all of the above automatically, no formula needed.

The Time Duration Formula

It's simple: subtract the start time from the end time. If you started at 9:00 AM and finished at 5:30 PM, the duration is 8 hours and 30 minutes. Two things complicate that basic subtraction: an overnight span, where the end time is a smaller number than the start time (add 24 hours to the end time first so the result comes out positive), and borrowing, when the end minute is smaller than the start minute. For ordinary timesheets this is all you need; if you're calculating exact elapsed time across a daylight-saving-time change, note that clocks shift by an hour on those dates, so simple clock subtraction can be off by an hour for that one day.

Worked Examples

StartEndCalculationDuration
9:00 AM5:30 PM17:30 − 09:008h 30m
9:45 AM12:20 PMBorrow 1 hour: 80−45m, 11−9h2h 35m
10:00 PM6:00 AM30:00 − 22:00 (+24h)8h
8:30 AM5:00 PM, 30m break8h 30m − 30m break8h

How to Calculate Duration of Time Manually

Before reaching for a tool, it helps to understand how to calculate time duration by hand. It comes down to three steps:

1

Write down both times

Convert both to 24-hour format so there's no AM/PM ambiguity, for example 2:15 PM becomes 14:15.

2

Subtract hours, then minutes, borrowing if needed

Subtract the start hour from the end hour, then the start minute from the end minute. If the minutes go negative, borrow an hour: for example, 9:45 AM to 12:20 PM is 20 − 45 minutes, which borrows 1 hour to become 80 − 45 = 35 minutes, and 11 − 9 = 2 hours, giving 2 hours 35 minutes.

3

Adjust for overnight spans

If the result is negative, add 24 hours to the end time first. This is how to calculate time duration manually for any two clock times, including shifts that cross midnight.

How to Calculate Duration Between Two Times

Most day-to-day cases involve figuring out the gap within the same day, a meeting, a shift, or a task. The same subtraction method applies whether you're trying to calculate time between two times for a call log or figure out how to calculate hours between two times for a timesheet. If you're totaling up a shift, this is also how you calculate work hours between two times before subtracting any unpaid breaks.

How to Calculate Time Duration Between Two Dates

Spans longer than a single day need a different approach, and it depends on what kind of answer you actually want. For a total elapsed duration (just the number of days, hours, or minutes between two timestamps), subtract the two dates directly. For a calendar difference expressed as years, months, and days, for example, "2 years, 3 months, 10 days", you can't just divide the day count by 30, since months and years don't have a fixed length. This is how to calculate duration of time between two dates correctly for that case: count full years and months first, then the remaining days. A time between two dates calculator gives you both at once, exact years, months, days, hours, and minutes, automatically, useful for project timelines, contract lengths, or counting down to an event.

Breaking Duration Into Hours, Minutes, and Seconds

Once you have the raw difference, break it into a readable format. The whole-number part is the easy part, that's how to calculate duration in hours. Beyond that, how to calculate duration in minutes just means carrying the leftover hours down one level (× 60), and how to calculate duration in seconds works the same way, converting any leftover minutes (× 60). If your task only needs whole numbers, how to calculate hours and minutes on their own is enough, and you can drop the seconds for a simpler result.

Convert Time Duration to Decimal Hours

Payroll and invoicing usually need a single decimal number instead of hours and minutes. If you need to know how to calculate duration of time in decimal hours, divide the minutes by 60 and add that to the whole hours, for example 1 hour 30 minutes becomes 1.5, so it can be multiplied directly by an hourly rate. See our Decimal Hours guide for a full conversion chart.

How to Calculate Duration of Time in Excel

In Excel or Google Sheets, format both cells as time, then use =MOD(B2-A2,1) instead of a plain subtraction. The MOD function automatically wraps a negative result back into a correct positive duration, so the same formula works whether the shift stays within one day or crosses midnight, no separate "if negative" logic needed. Format the result cell as [h]:mm so it doesn't reset at 24 hours.

How to Calculate Duration of Time for Work Hours

For payroll, this usually means clock-out minus clock-in, minus any unpaid breaks. Subtract the total break minutes from the gross shift length to get net hours worked, then convert to decimal hours if your payroll system requires it. See our Billable Time Tracking guide for the freelance/invoicing version of this same process.

How to Calculate Overnight Time Duration

Overnight shifts trip up manual math because the end time is a smaller clock value than the start time. The fix is simple: add 24 hours to the end time before subtracting, for example, 10:00 PM to 6:00 AM becomes 22:00 to 30:00, giving you a correct 8-hour result instead of a negative number.

How to Calculate Elapsed Time

Elapsed time is really just duration measured from a starting point to now, or to a defined end point, and it follows the exact same subtraction rules covered above. If you're checking this often, an elapsed time calculator is faster than redoing the subtraction by hand every time.

Related Guides

Frequently Asked Questions

How to calculate duration of time without doing manual math?

Enter your start and end time (or start and end date) into a free online calculator. It instantly returns the result in hours, minutes, seconds, and decimal hours, no formula required.

How to calculate time difference between two times?

Subtract the start time from the end time. If the end time is smaller than the start time (an overnight span), add 24 hours before subtracting. The result is your time difference in hours and minutes. A time difference calculator does this same subtraction for you automatically.

Does this work for dates as well as times?

Yes. For a single day, subtract clock times directly. For spans longer than a day, use a date-based calculator so leap years and different month lengths are handled correctly instead of assuming every month has 30 days.