To subtract hours in Excel, use a simple subtraction formula: =End_Time - Start_Time. Because Excel treats time as a fraction of a 24-hour day, the result will automatically be formatted as a time value if the cells are set correctly. If your calculation spans across midnight or exceeds 24 hours, you must apply a custom number format [h]:mm to prevent the clock from resetting to zero.
What You'll Need
- Microsoft Excel (any version, including Office 365, Excel 2021, or Excel for Web).
- A dataset containing start times and end times.
- Basic knowledge of how to enter a formula into a cell.
Step-by-Step
- Enter Your Data: Input your start time in one cell (e.g., A2) and your end time in another cell (e.g., B2). Use a recognized time format such as "8:00 AM" or "17:00" (military time). Excel recognizes these formats automatically and converts them into numerical values behind the scenes.
- Insert the Subtraction Formula: Click on the cell where you want the result to appear (e.g., C2). Type the equals sign
=, click on the end time cell, type the minus sign-, and then click on the start time cell. The final formula should look like=B2-A2. - Press Enter: Once you hit Enter, Excel will calculate the difference. If both cells were formatted as time, the result will likely appear as a time value (e.g., 08:00).
- Apply Custom Formatting for Totals: If you are summing multiple subtractions and the total exceeds 24 hours, Excel will default to showing the remainder (e.g., 26 hours will show as 2 hours). To fix this:
- Right-click the result cell and select Format Cells.
- Go to the Number tab and select Custom from the Category list.
- In the Type box, manually type
[h]:mm. The square brackets tell Excel to accumulate hours rather than resetting every 24 hours. - Click OK.
- Convert Time to Decimals (Optional): If you need the result as a decimal number (e.g., 8.5 hours instead of 8:30) for payroll or multiplication by an hourly rate, use this formula:
=(B2-A2)*24. After entering this, you must change the cell format to Number or General, otherwise, it will look like a strange time value.
Common Mistakes
The most frequent error when subtracting hours is ignoring the 24-hour wrap-around. If a shift starts at 10:00 PM and ends at 6:00 AM the next day, a simple =End-Start formula will result in a negative number. Since Excel cannot display negative times by default, it will show a string of hashtags (#######) across the cell. This happens because Excel sees the end time as a smaller number than the start time.
Another common mistake is mixing data types. Users often type "8 hours" into a cell instead of "8:00". When you add text (the word "hours") to the cell, Excel treats the entire entry as a string of text rather than a numerical value. This leads to the #VALUE! error because you cannot perform mathematical subtraction on text.
Finally, many users forget to change the cell format after multiplying by 24. When you multiply a time difference by 24 to get a decimal, Excel often tries to be "helpful" by keeping the time format. This results in a result like "12:00 AM" when the actual answer is 0.5 hours. Always ensure the destination cell is set to Number for decimal results.
Tips
To handle the "midnight problem" mentioned earlier without adding dates to your cells, use the MOD function. The formula =MOD(B2-A2, 1) tells Excel to find the remainder after dividing by 1. In practical terms, if the subtraction results in a negative number, the MOD function flips it to the correct positive duration for a 24-hour cycle. This is the cleanest way to calculate overnight shifts.
If you are working with very large datasets, use a Table (Ctrl + T). When you enter the subtraction formula in the first row of a Table, Excel will automatically fill the formula down to the bottom of the column, saving you from manually dragging the fill handle.
For those needing high precision, remember that Excel stores time as a fraction of 1. For example, 12 hours is stored as 0.5. If you ever see a decimal like 0.333 when you expected 8 hours, it simply means your cell is formatted as General instead of Time.
Troubleshooting
If you see a series of hashtags (#######): This usually means the result is a negative time or the column is too narrow. First, widen the column. If the hashtags remain, your end time is likely earlier than your start time (e.g., an overnight shift). Use the =MOD(B2-A2, 1) formula to resolve this.
If you see the #VALUE! error: Check your input cells. Ensure there are no letters, spaces, or hidden characters in the time cells. Ensure you are using a colon (:) to separate hours and minutes, not a period (.) or a comma (,). If you imported the data from another software, try using the Data > Text to Columns tool to ensure the cells are recognized as numbers/times.
If the total hours are incorrect (e.g., 100 hours shows as 4): This is a formatting issue, not a math issue. Your cell is using the standard h:mm format, which resets every 24 hours. Go to Format Cells > Custom and change the format to [h]:mm. The brackets are the key to displaying cumulative hours.
If the result is a decimal like 0.25 instead of 6:00: Your cell is formatted as General. Right-click the cell, select Format Cells, and choose Time from the list. This will convert the internal decimal back into a human-readable time format.
Frequently Asked Questions
How do I subtract hours if the time spans multiple days?
The most accurate way is to include the date in the cell (e.g., "2023-10-01 22:00"). When you subtract two cells that contain both date and time, Excel calculates the absolute difference regardless of how many days have passed. Then, apply the [h]:mm format to see the total hours.
Can I subtract a specific number of hours (like a 30-minute break) from a total?
Yes. You can subtract time using the TIME function. For example, to subtract 30 minutes from a result in cell C2, use =C2 - TIME(0, 30, 0). The arguments for the TIME function are (hours, minutes, seconds).
Why does my time subtraction result in a date like "January 0, 1900"?
This happens when the result is a very small positive number and the cell is formatted as a Date instead of Time. Change the cell format to Time or Custom [h]:mm to see the duration.
How do I calculate the difference between two times in minutes only?
Subtract the times as usual =(B2-A2), then multiply the result by 1440 (which is 24 hours * 60 minutes). Ensure the result cell is formatted as Number or General.
What is the difference between h:mm and [h]:mm?
The h:mm format is a clock format; it shows the time of day and resets to 0 after 23:59. The [h]:mm format is a duration format; it allows the hours to climb indefinitely (e.g., 48:00, 150:00), making it essential for timesheets.
Can I subtract hours using a formula if the times are in different time zones?
Excel does not have a built-in time zone converter. You must first normalize the times to a single time zone (like UTC) by adding or subtracting the offset hours before performing the final subtraction.