How to Calculate Time Worked in Excel
In this article
To calculate time worked in Excel, subtract the start time from the end time (End − Start), then format the result as a time or as decimal hours. If the shift crosses midnight, use the formula =MOD(End−Start,1) so Excel handles the overnight rollover. For a running total, sum the daily results and format the total as [h]:mm so it can exceed 24 hours without resetting.
What You'll Need
- Excel (desktop or web) or a compatible spreadsheet app.
- Start and end times entered as actual time values, not plain text.
- Basic familiarity with cell references and the Format Cells dialog.
Step-by-Step
- Set up your columns. In a new sheet, label A1 “Date”, B1 “Start”, C1 “End”, and D1 “Hours Worked”. Leave a row for each shift.
- Enter times correctly. Type times as
9:00 AMor09:00(24-hour). Excel recognises these as time values. If you type9alone, Excel treats it as a number, not 9:00. To force a time, type9:00or use=TIME(9,0,0). - Write the basic subtraction formula. In D2, enter
=C2-B2. Press Enter. If B2 is 9:00 AM and C2 is 5:00 PM, D2 shows 8:00 (or 0.3333 if formatted as General). - Format the result as hours and minutes. Select D2, right-click and choose Format Cells (or press Ctrl+1). On the Number tab, pick Time, then choose the
h:mmformat. Click OK. The cell now displays 8:00. - Handle overnight shifts. If a shift starts at 10:00 PM and ends at 6:00 AM the next day, plain subtraction gives a negative time (displayed as ######). Use
=MOD(C2-B2,1)instead. This wraps the difference into a positive time value. Format the cell ash:mm. - Convert to decimal hours (for payroll). In a new column, enter
=D2*24and format as Number with two decimals. An 8-hour shift becomes 8.00; 7 hours 30 minutes becomes 7.50. This is the value most payroll systems expect. - Sum multiple shifts. In a cell below your daily results, enter
=SUM(D2:D10). Format that total cell as[h]:mm(with square brackets around the h). Without the brackets, a total of 25 hours displays as 1:00 because Excel resets at 24 hours. The brackets tell Excel to keep counting past 24. - Subtract unpaid breaks. If you track a lunch break, add a “Break” column (for example 0:30 for 30 minutes) and change the formula to
=C2-B2-E2, or=MOD(C2-B2,1)-E2for overnight shifts. Format the break column ash:mmso Excel reads it as a time, not text. - Check for text entries. If a time cell is left-aligned, it is probably text. Select the column, then use Data > Text to Columns > Finish, or re-type the value with a colon. Formulas return #VALUE! when they meet text.
- Copy the formulas down. Drag the fill handle from D2 down your rows. Relative references adjust automatically. Verify one row manually to confirm the result matches the times you entered.
Common Mistakes
- Formatting the total as h:mm instead of [h]:mm. The total resets every 24 hours, so a 30-hour week shows as 6:00. Use square brackets.
- Typing times as text. Entries like “9am” or “9.00” may be stored as text and break formulas. Use a colon and AM/PM, or 24-hour format.
- Forgetting the MOD function for overnight shifts. Plain subtraction produces negative values, shown as ######.
- Multiplying by 24 but leaving the cell formatted as Time. The decimal result appears as a strange time. Format the decimal column as Number.
- Mixing date and time. If a cell contains a full date-time (e.g., 1/15/2025 9:00 AM), subtraction still works, but the result may include days. Format as
[h]:mmto see total hours. - Using a break column formatted as General. A break typed as 0.5 means half a day, not 30 minutes. Enter breaks as
0:30and format as Time.
Tips
- Use 24-hour time entry to avoid AM/PM mistakes, especially for afternoon and evening shifts.
- Apply the
[h]:mmformat to any cell that sums time, including weekly and monthly totals. - Keep a separate column for “Break” and subtract it in the formula so the original start and end times stay intact.
- Use
=ROUND((C2-B2)*24,2)if you need decimal hours rounded to two places for payroll. - Freeze the header row (View > Freeze Panes) when your timesheet grows beyond one screen.
- Test one row with known values (9:00 AM to 5:00 PM should give 8:00) before filling down.
Troubleshooting
- Result shows ######. The column is too narrow or the value is negative. Widen the column; if the value is negative, switch to MOD for overnight shifts.
- Result shows a date like 1/0/1900. The cell is formatted as Date. Change the format to Time or Number.
- #VALUE! error. One of the cells contains text. Check alignment (text is left-aligned by default) and re-enter the time with a colon.
- Total shows 1:00 instead of 25:00. The total cell is formatted as h:mm. Apply the custom format
[h]:mm. - Overnight shift gives a negative number. Replace
=C2-B2with=MOD(C2-B2,1). - Decimal hours look wrong. Confirm you multiplied by 24 and formatted the cell as Number, not Time.
Frequently Asked Questions
Why does Excel show ###### when I subtract times?
Either the column is too narrow or the result is negative (common with overnight shifts). Widen the column first; if it persists, use =MOD(End−Start,1).
How do I calculate total hours for a week that exceeds 24?
Sum the daily results with =SUM(range) and format the total cell as [h]:mm. The square brackets prevent the total from resetting at 24 hours.
Can I subtract a lunch break from the total?
Yes. Add a break column formatted as Time (e.g., 0:30) and subtract it in the formula: =C2-B2-E2. For overnight shifts, use =MOD(C2-B2,1)-E2.
How do I convert hours and minutes to decimal hours?
Multiply the time difference by 24: =(C2-B2)*24. Format the result as Number with two decimals. For example, 7:30 becomes 7.50.
Why does my formula return a date instead of hours?
The cell is formatted as Date. Select it, open Format Cells (Ctrl+1), and choose Time or Number instead.
Does this work in Excel for the web and Google Sheets?
Yes. The same subtraction, MOD, and [h]:mm formatting work in Excel for the web and Google Sheets, though menu labels may differ slightly by version and platform.