Yes, Excel can calculate elapsed time, add or subtract hours, and convert time into decimal hours—but only if you use the right formulas and number formats. The core trick is that Excel stores times as fractions of a 24-hour day (so 6:00 AM is 0.25), which is why a simple subtraction like =B2-A2 works for most time differences. This guide walks you through the essential formulas for tracking work hours, project durations, or any time-based calculation, and shows you how to avoid the common pitfalls that produce negative or garbled results.
What You'll Need
- Excel (2016, 2019, 2021, or Microsoft 365—all have the same time functions).
- A worksheet with time entries typed in a consistent format, e.g.,
9:00 AMor14:30. Excel recognizes both 12-hour and 24-hour formats. - Basic familiarity with entering formulas (starting with an equals sign).
Step-by-Step
1. Calculate the difference between two times
- Suppose column A has start times and column B has end times. In cell C2, enter:
=B2-A2. - Press Enter. Excel will display the result as a time (e.g., 8:30) if the cells are formatted as time. If you see a decimal like 0.354, that’s actually correct—it’s the fraction of a day. To show it as hours and minutes, right-click the cell, choose Format Cells > Time, and pick a format like 1:30 PM or 13:30.
- Copy the formula down for other rows.
This works for any times on the same day. If the end time is on the next day (e.g., start 10:00 PM, end 2:00 AM), the simple subtraction gives a negative number. Fix that with the formula =IF(B2>A2, B2-A2, (B2+1)-A2). The +1 adds a full day to the end time, so the difference becomes positive.
2. Sum total hours for a week or project
- If you have daily time differences in column C (from step 1), use
=SUM(C2:C8)to add them up. - Excel will show the sum as a time value, but if the total exceeds 24 hours, it will “roll over” and display something like 2:30 instead of 26:30. To fix this, format the total cell as [h]:mm (custom format). Right-click the cell > Format Cells > Custom, and type
[h]:mmin the Type box. This shows total hours beyond 24.
3. Convert time to decimal hours (for payroll or billing)
- To convert a time difference (like 8:30) into decimal hours (8.5), multiply by 24:
=(B2-A2)*24. - Format the result as a number (not time) with 2 decimal places. This is the standard for calculating hourly pay or billable hours.
4. Add or subtract a specific number of hours
- To add 3 hours to a time in A2, use
=A2+TIME(3,0,0). TheTIMEfunction takes hours, minutes, seconds as arguments. - To subtract 45 minutes, use
=A2-TIME(0,45,0). - For adding more than 24 hours (e.g., 30 hours), use
=A2+30/24because 30 hours is 30/24 of a day. Format the result as[h]:mmto see total hours.
5. Use the MOD function for overnight shifts
- For a more robust overnight formula, use
=MOD(B2-A2,1). This returns the positive remainder after dividing by 1 day, so it always gives the correct elapsed time even if B2 is smaller than A2. - Example: A2=10:00 PM, B2=2:00 AM.
MOD(2:00 AM - 10:00 PM, 1)= 0.1667, which is 4 hours. Format as time to see 4:00.
6. Calculate time in minutes or seconds
- To get the difference in minutes, multiply by 1440 (24*60):
=(B2-A2)*1440. - For seconds, multiply by 86400 (24*60*60):
=(B2-A2)*86400. - Use these when you need finer granularity than hours.
Common Mistakes
- Not formatting the result cell as time. If you see a decimal like 0.5, that’s 12 hours. Format as time to display 12:00.
- Using a 24-hour clock inconsistently. Mixing “2:00” (meaning 2 AM) with “14:00” (2 PM) will cause errors. Stick to one format.
- Forgetting to handle overnight shifts. Simple subtraction fails when start time is later than end time. Use the IF or MOD formula.
- Summing times that exceed 24 hours without the [h]:mm format. Excel will wrap around, showing a lower number than expected.
Tips
- Use Excel’s built-in time picker (Ctrl+Shift+:) to insert the current time quickly, but remember it’s static—it won’t update automatically.
- If you’re entering many times, type them in 24-hour format (e.g., 14:30) to avoid AM/PM confusion. Excel will display them in whatever format you set.
- For payroll, round times to the nearest quarter hour using
=ROUND((B2-A2)*96,0)/96. The 96 comes from 24 hours * 4 quarters. - Use a named range for your time cells to make formulas easier to read, e.g.,
=SUM(WorkHours).
Troubleshooting
If the result shows ########## – The column is too narrow. Widen it or change the format to a shorter time format.
If the result is a negative time (like -0.25) – This usually means the start time is later than the end time without an overnight adjustment. Use the IF or MOD formula described above.
If the formula returns a #VALUE! error – Check that the cells contain actual time values, not text. Try re-entering them with a colon (e.g., 9:00) or using the TIME function: =TIME(9,0,0).
If the sum of times shows a small number like 2:30 when you expected 26:30 – Apply the custom format [h]:mm to the sum cell.
If the decimal conversion gives an incorrect number – Ensure the cell is formatted as a number, not as time. A time format will display 8:30 instead of 8.5.
Frequently Asked Questions
How do I calculate time difference in Excel over 24 hours?
Use the formula =MOD(B2-A2,1) and format the result as [h]:mm to show total hours, even if they exceed 24.
Why does Excel show a decimal instead of hours?
Because Excel stores times as fractions of a day. Format the cell as Time (e.g., 1:30 PM) to see hours and minutes, or multiply by 24 to get decimal hours.
Can I calculate time in minutes only?
Yes. Use =(B2-A2)*1440 and format the result as a number. This gives total minutes.
How do I add 8 hours to a time in Excel?
Use =A2+TIME(8,0,0) for a time within the same day, or =A2+8/24 if you want to display total hours beyond 24.
What if my time entries are text like “9:00” not recognized as time?
Convert them using =TIMEVALUE(A2) to turn text into a time value, then use that in your calculations.
How do I calculate time between two dates and times?
If you have full date-time values (e.g., 2023-01-01 9:00), simply subtract them: =B2-A2. Format the result as [h]:mm to see total hours, or as a number to see days (e.g., 1.5 = 1 day 12 hours).