To find the hours worked in Excel, subtract the start time from the end time (End Time - Start Time) and format the result as a Time or Custom number format. If the shift crosses midnight, use the formula =MOD(End_Time - Start_Time, 1) to prevent negative time errors.
Calculating work hours is a fundamental task for payroll, project management, and freelancers. Because Excel treats time as a fraction of a 24-hour day (where 1.0 equals 24 hours), simply subtracting cells often results in decimals or strange formatting. This guide ensures you get a clean, readable total of hours and minutes.
What You'll Need
- Microsoft Excel (Desktop, Web, or Mobile version)
- A dataset containing "Start Time" and "End Time" for each shift
- Basic knowledge of how to enter a formula in a cell
Step-by-Step
- Set Up Your Columns: Create a table with three headers: "Start Time" in cell A1, "End Time" in cell B1, and "Total Hours" in cell C1.
- Enter Your Data: Input your times in the cells below the headers. Use a colon to separate hours and minutes (e.g., 8:00 AM or 17:00). Excel generally recognizes these as time values automatically.
- Apply the Basic Formula: In cell C2, type the formula
=B2-A2and press Enter. This subtracts the start time from the end time. - Format the Result: If the result looks like a decimal (e.g., 0.33) or a strange time, you must change the cell format:
- Right-click the cell (or the entire C column) and select Format Cells.
- Under the Number tab, select Time.
- Choose the format that looks like "13:30" or "37:30:55".
- Handle Overnight Shifts: If a shift starts at 10:00 PM and ends at 6:00 AM the next day, the basic subtraction formula will result in an error (#####) because Excel cannot display negative time. To fix this, use the MOD formula in cell C2:
=MOD(B2-A2, 1). This tells Excel to treat the time as a 24-hour cycle. - Calculate a Grand Total: To sum all hours for a week or month, use the
=SUM(C2:C10)formula at the bottom of your total hours column. - Fix the "24-Hour Reset" Issue: By default, if your total hours exceed 24, Excel resets the clock to zero. To show the actual total (e.g., 45 hours instead of 21 hours), do the following:
- Right-click the total cell and select Format Cells.
- Go to Custom.
- In the "Type" box, manually type
[h]:mm. The square brackets tell Excel to accumulate hours rather than resetting at 24.
Common Mistakes
- Incorrect Time Entry: Entering "800" instead of "8:00". Without the colon, Excel treats the entry as a whole number rather than a time value, making formulas fail.
- Forgetting the [h] Format: Using a standard time format for a weekly total. This leads to the "reset" problem where 25 hours is displayed as 1 hour.
- Mixing Date and Time: Entering a date and time in one cell but only a time in another. For the subtraction to work simply, both cells should be formatted as Time, or both as Date/Time.
- Using AM/PM Inconsistently: Mixing 24-hour time (14:00) and 12-hour time (2:00 PM) in the same column can sometimes lead to data entry errors if the user forgets to specify PM.
Tips
- Quick Time Entry: Use
Ctrl + Shift + :(colon) to quickly insert the current system time into a cell. - Convert to Decimals for Payroll: If you need to multiply hours by an hourly rate (e.g., 8 hours 30 minutes * $20), you cannot multiply the "Time" format directly. You must convert the time to a decimal by multiplying the result by 24. Example:
=(B2-A2)*24. Then, format that cell as a "Number" or "Currency". - Use Tables: Convert your data range into an official Excel Table (Insert > Table). This ensures that when you add a new row of hours, your formulas and formatting are automatically applied.
Troubleshooting
If your calculations are not working as expected, try these steps in order:
- Check for "#####" Errors: This usually means the result is a negative number (common in overnight shifts) or the column is too narrow. Try widening the column first; if that fails, use the
=MOD(B2-A2, 1)formula. - Verify Data Types: Click on a time cell and look at the "Number" dropdown in the Home tab. If it says "Text", your formulas won't work. Re-type the time or use the "Text to Columns" feature to convert it to a number.
- Check for Hidden Spaces: Sometimes data imported from other software contains hidden spaces. Use the
=TRIM()function to clean the cells if the formula returns a #VALUE! error. - Reset Formatting: If the cell looks completely wrong, select the cell, go to the Home tab, and select "Clear" > "Clear Formats" to start fresh.
Frequently Asked Questions
How do I subtract a lunch break from total hours?
Subtract the break duration from your final result. If your break is 30 minutes, your formula would be =(B2-A2)-TIME(0,30,0). Alternatively, create a separate "Break" column and subtract that cell from the total.
Why does my total show 1 hour when it should be 25?
Excel resets the hour count every 24 hours. To fix this, go to Format Cells > Custom and change the format to [h]:mm.
Can I calculate hours if I only have the start and end times without dates?
Yes, as long as the shift does not cross midnight. If it does cross midnight, you must use the =MOD(End-Start, 1) formula to account for the date change.
How do I convert 8:30 (time) to 8.5 (decimal)?
Multiply the time result by 24. For example: =(B2-A2)*24. Ensure the cell format is set to "Number" or "General" rather than "Time".
Does this work on Excel for Mac and Excel Online?
Yes, these formulas and formatting options are standard across all versions of Excel, including Mac, Windows, and the web-based version.