To calculate hours in Excel, use the formula =End Time - Start Time, then format the result as [h]:mm to show total hours (even over 24). For example, if A1 has 9:00 AM and B1 has 5:30 PM, enter =B1-A1 in C1 and format C1 as [h]:mm to get 8:30. This works for time differences, timesheets, and payroll. If you need to sum multiple days, use =SUM(C1:C10) with the same format. This guide covers the exact steps, common errors, and fixes.

What You'll Need

  • Microsoft Excel (2016, 2019, 365, or any recent version; steps are similar in Google Sheets).
  • Time data entered as time values (e.g., 9:00 AM, not 9.00).
  • Basic familiarity with entering formulas and formatting cells.

Step-by-Step

  1. Enter your times correctly. In separate cells, type the start time and end time using a format Excel recognizes, like 9:00 AM or 17:30. Avoid typing times as text (e.g., "9am") because Excel won't calculate them. For example, put start time in A2 and end time in B2.
  2. Write the subtraction formula. Click on the cell where you want the hours to appear (e.g., C2). Type =B2-A2 and press Enter. Excel will show a decimal number like 0.35417, which is the fraction of a day. That's okay—you'll format it next.
  3. Format the result as time. Right-click the cell with the formula, choose Format Cells (or press Ctrl+1). Go to the Number tab, select Time, and choose a format like 13:30 (24-hour) or 1:30 PM. Click OK. The cell now shows the difference as hours and minutes.
  4. Handle times that cross midnight. If a shift starts at 10:00 PM and ends at 6:00 AM, the simple formula =B2-A2 returns a negative number (or ####). To fix this, use =MOD(B2-A2,1). The MOD function wraps around midnight, giving 8:00 hours. Apply the same time format.
  5. Sum total hours for a week or project. After you have individual day calculations in column C (C2:C8 for a week), click an empty cell (e.g., C9) and enter =SUM(C2:C8). Then format that cell as [h]:mm—this is crucial. The square brackets tell Excel to show total hours beyond 24 (like 40:00 instead of 16:00). To apply this format, go to Format Cells > Custom and type [h]:mm.
  6. Convert hours to decimal for payroll (optional). If you need hours as a decimal number (e.g., 8.5 instead of 8:30), multiply the time difference by 24. Use =(B2-A2)*24 and format the cell as a number (not time). For example, 8:30 becomes 8.5. This is common for payroll calculations.
  7. Calculate overtime or night shift differentials (if needed). For example, to find hours worked after 6:00 PM, use =MAX(0, B2 - TIME(18,0,0)) if B2 is the end time and the shift ends after 6 PM. This returns the hours between 6 PM and the end time. Adjust the TIME function for your threshold.

Common Mistakes

  • Not formatting the result as time. If you see a decimal like 0.35, that's a fraction of a day. You must format the cell as time to see hours and minutes.
  • Using plain numbers instead of time values. Entering 9.5 for 9:30 AM will break calculations. Always use a colon (9:30) or AM/PM.
  • Forgetting to use MOD for overnight shifts. A formula like =B2-A2 will give a negative time or #### if the end time is earlier than the start time (e.g., 6:00 AM vs 10:00 PM). Use =MOD(B2-A2,1).
  • Summing with a regular time format. If you sum hours that exceed 24, a standard format like hh:mm will reset to 0 after 24 hours. Use [h]:mm to display total hours correctly.
  • Including text in time cells. If a cell contains "9:00" as text (left-aligned), Excel won't calculate it. Re-enter as time or use TIMEVALUE().

Tips

  • Use keyboard shortcuts. Press Ctrl+1 to open Format Cells quickly. Use Ctrl+Shift+3 to apply the time format directly.
  • Pre-format columns. Before entering data, select the start and end time columns and set them to a time format. Then Excel will automatically convert what you type into time values.
  • Use a 24-hour clock for clarity. Entering 17:30 is unambiguous and avoids AM/PM errors. Format as 13:30.
  • Test with a known example. Try 9:00 AM to 5:00 PM; the result should be 8:00. If you get 0.333, you forgot to format.
  • Create a timesheet template. Set up columns for Date, Start, End, and Total. Copy the formula down. This saves time for recurring use.

Troubleshooting

If the result shows ##### (hashes): The column is too narrow. Double-click the column header boundary to auto-fit, or widen it manually. If the value is negative, use MOD.

If the result is a decimal like 0.35: You haven't applied a time format. Right-click > Format Cells > Time.

If the sum shows 16:00 instead of 40:00: You used a standard time format. Change the format to Custom > [h]:mm.

If the formula returns #VALUE!: One of the cells contains text or an invalid time. Check that both cells are actual time values. Re-enter them.

If the result is negative (e.g., -2:00): The end time is earlier than the start time. Use =MOD(B2-A2,1) for overnight shifts, or adjust the times.

If the time difference is correct but shows AM/PM incorrectly: Change the format to 13:30 (24-hour) or use a custom format like h:mm.

Frequently Asked Questions

How do I calculate hours between two dates and times?

Subtract the start date-time from the end date-time: =End - Start. Format as [h]:mm to get total hours. For example, if A1 has 1/1/2024 9:00 AM and B1 has 1/2/2024 5:00 PM, the formula gives 32:00.

Can I calculate hours in Excel without using formulas?

No, Excel doesn't have a built-in "duration" function. You must use a formula like =B2-A2. However, you can use the Status Bar: select the cells with times, and Excel shows the sum in the bottom bar (but not the difference).

How do I calculate overtime hours in Excel?

Use a formula like =MAX(0, (B2-A2) - TIME(8,0,0)) to get hours beyond 8. Adjust the 8:00 to your regular hours. For example, if a shift is 9:00 AM to 6:00 PM (9 hours), the formula returns 1:00.

Why does my time difference show as a fraction like 0.5?

Excel stores times as fractions of a day. 0.5 equals 12:00 PM. To see hours and minutes, format the cell as time. To see decimal hours, multiply by 24.

Can I calculate hours worked from a start time and a duration?

Yes. To find the end time, add the duration (as a time) to the start time: =Start + Duration. For example, =9:00 AM + 8:30 gives 5:30 PM. Format the result as time.

How do I handle times that span midnight in a sum?

Use the MOD formula for each day, then sum those results. For example, =MOD(B2-A2,1) gives the correct hours for an overnight shift. Summing those with =SUM() works normally.