Excel Formulas to Subtract Time and Calculate Time Differences

📅 Mar 06, 2026 📝 Sarah Miller

Tracking and subtracting elapsed time in Excel often leads to frustrating formatting errors, such as the dreaded ### display. When managing initiatives supported by standard funding sources like corporate budgets or operational grants, precise hour logging is critical. Accurately calculating these intervals grants stakeholders total visibility into resource allocation and project costs. However, one key stipulation is that Excel cannot natively display negative times; your end time must always succeed the start time. For example, subtracting start time in cell A2 (9:00 AM) from end time in B2 (5:00 PM) using =B2-A2 requires custom formatting. Below, we break down the exact formulas to master time subtraction.

Excel Formulas to Subtract Time and Calculate Time Differences

Understanding How Excel Handles Time

Before diving into the formulas for subtracting time in Excel, it is crucial to understand how Excel stores and processes time values. Under the hood, Excel does not see "12:00 PM" as text or a unique time object. Instead, it treats dates and times as serial numbers.

In Excel's system:

  • 1 day is represented by the integer 1.
  • 24 hours equal 1.0.
  • 12 hours (half a day) equal 0.5.
  • 1 hour is represented as 1/24 (approximately 0.04167).
  • 1 minute is represented as 1/1440 (approximately 0.000694).

Because times are stored as fractional decimal numbers, subtracting time in Excel is essentially basic subtraction. However, displaying that result correctly and managing shifts that cross midnight require specific formulas and formatting rules.

Method 1: The Basic Time Subtraction Formula

If you are subtracting two times that occur on the same day (where the end time is larger than the start time), you can use a simple subtraction formula.

The Formula:

=End_Time - Start_Time

Step-by-Step Example:

Imagine you have a project tracking sheet with a start time in cell A2 (9:00 AM) and an end time in cell B2 (5:30 PM).

  1. In cell C2, enter the formula: =B2-A2
  2. Press Enter.
  3. If the result displays as a decimal (e.g., 0.35417), you need to change the cell format.
  4. Right-click cell C2, select Format Cells, choose Time, and select your preferred display format (e.g., 13:30 or 1:30 PM).
Start Time (A) End Time (B) Formula Result (Formatted as Time)
08:00 AM 05:00 PM =B2-A2 09:00
13:15 17:45 =B3-A3 04:30

Method 2: How to Subtract Time Across Midnight

The standard subtraction formula works flawlessly until your timespan crosses midnight. For example, if a night shift worker starts at 10:00 PM (22:00) and finishes at 6:00 AM the next morning, a standard =End_Time - Start_Time calculation will result in a negative number (6:00 - 22:00 = -16:00).

Because Excel cannot display negative times by default, it will show a string of hash symbols: ######.

To solve this, you can use two highly reliable formulas.

Option A: The MOD Function (Recommended)

The MOD function returns the remainder after a number is divided by a divisor. It is an incredibly elegant way to handle shifts that cross midnight without using complex IF statements.

The Formula:

=MOD(End_Time - Start_Time, 1)

How it works: Because times are decimals less than 1, dividing a positive difference by 1 returns the same positive difference. If the difference is negative (which happens when crossing midnight), the MOD function automatically adds 1 (a full 24-hour day) to the result, correcting the calculation.

Option B: The IF Function

Alternatively, you can write a logical statement that checks if the end time is less than the start time. If it is, Excel adds 1 day to the end time before performing the subtraction.

The Formula:

=IF(End_Time >= Start_Time, End_Time - Start_Time, (End_Time + 1) - Start_Time)

Method 3: Calculating Time Differences in Specific Units

Sometimes you do not want your result formatted as a time (e.g., "08:30"). Instead, you might need the total decimal hours to calculate payroll, or total minutes to track server downtime.

1. Calculating Decimal Hours

To convert Excel's internal fractional representation of a day into hours, subtract the times and multiply the result by 24.

=(End_Time - Start_Time) * 24

Note: If you are crossing midnight, wrap the calculation in a MOD function first:

=MOD(End_Time - Start_Time, 1) * 24

Crucial Formatting Step: You must change the cell format of the formula cell to General or Number. If left formatted as Time, your calculated decimal (like 8.5 hours) will display incorrectly as a clock value.

2. Calculating Total Minutes

Since there are 1,440 minutes in a full day (24 hours × 60 minutes), subtract the times and multiply by 1440.

=(End_Time - Start_Time) * 1440

3. Calculating Total Seconds

Since there are 86,400 seconds in a day (24 hours × 60 minutes × 60 seconds), multiply the subtraction result by 86400.

=(End_Time - Start_Time) * 86400

Method 4: Subtracting Dates and Times Combined

When tracking processes that span multiple days, it is highly recommended to enter both the date and time into your starting and ending cells (e.g., 10/23/2023 14:00). When Excel has access to both the date and the time, subtracting is straightforward and immune to midnight errors.

The Formula:

=End_DateTime - Start_DateTime

If you subtract 10/25/2023 17:00 from 10/23/2023 14:00, the raw decimal result is 2.125 (which represents 2 days and 3 hours). You can format this result in custom ways to make it human-readable.

Formatting Time Differences Over 24 Hours

By default, when you format a cell as Time (such as hh:mm), Excel resets the clock to 0 every time it hits 24 hours. For example, if you subtract two timestamps and the duration is 26 hours, Excel will display 02:00 instead of 26:00.

To prevent this and show elapsed time exceeding 24 hours, apply a Custom Number Format:

  1. Select the cells with your time calculation.
  2. Press Ctrl + 1 (or Command + 1 on Mac) to open the Format Cells dialog.
  3. Under Category, select Custom.
  4. In the Type text box, enter: [h]:mm:ss (or [h]:mm if you do not need seconds).
  5. Click OK.

The square brackets around the [h] instruct Excel to accumulate the hours indefinitely rather than rolling them over into days.

Using the TEXT Function to Format Outcomes

If you need the result of your time subtraction integrated into a sentence or text-based report, the TEXT function is highly useful. It converts your time subtraction math directly into a structured text string.

Standard Formatting:

=TEXT(End_Time - Start_Time, "h \h\o\u\r\s \a\n\d m \m\i\n\u\t\e\s")

If the difference is 3 hours and 15 minutes, this formula output displays as: 3 hours and 15 minutes.

Common Troubleshooting and Errors

  • ### Error: This almost always indicates that your time subtraction resulted in a negative value. Use the MOD function or ensure your End Time occurs chronologically after your Start Time. It can also mean the column is simply too narrow to display the time value.
  • Formula returns another date: If your output displays something like 1/0/1900 8:30, you have the cell formatted as a Date/Time. Simply change the formatting of the cell to Time or Custom [h]:mm to resolve this.
  • Calculation is slightly off: Excel uses floating-point math, which can occasionally lead to tiny rounding errors. If you need absolute precision to the millisecond, consider rounding your subtraction using the ROUND function before converting to minutes or hours.

Conclusion

Subtracting time in Excel is simple once you master how Excel manages chronological numbers. For basic, same-day calculations, a direct subtraction (B2 - A2) is all you need. For shifts that cross midnight, the MOD(B2-A2, 1) formula is your most robust option. Always remember to check your cell formatting to ensure your results display exactly as intended!

Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.