Calculating time duration in an Excel sheet is accomplished by subtracting the start time cell from the end time cell using the formula =B2-A2, where A2 contains the start time and B2 contains the end time, and then applying a custom number format of [h]:mm:ss to display cumulative hours beyond a 24-hour cycle. Excel treats time as a fractional part of a 24-hour day. For instance, six hours is represented internally as 0.25, while twelve hours is 0.5. Because of this underlying serial number system, subtracting a start time from a later end time yields a decimal value that represents the elapsed fraction of a day. To make this decimal readable to humans, spreadsheet software relies heavily on cell formatting rules. If you do not change the default time format, Excel will automatically reset the displayed duration to zero every time the accumulated total crosses a 24-hour mark, leading to highly inaccurate reports for timesheets, project schedules, or multi-day event tracking. By adjusting the cell formatting to bracket the hour symbol, you instruct the spreadsheet engine to display the absolute, cumulative elapsed hours. Alternatively, when you need a fast, error-free calculation without configuring complex custom formats, using a browser-based Time Duration Calculator provides an immediate breakdown of days, hours, minutes, and seconds.

how to calculate time duration in excel sheet
Calculate Time Duration in an Excel Sheet

Formulas for Measuring Time Differences in Excel

Depending on how your spreadsheet is structured, you can use a few different formulas to calculate elapsed time. The most straightforward approach is standard subtraction. When both your start and end times occur on the same calendar day, a direct math equation is highly effective.

Standard Subtraction Formula

If your start time is in cell A2 and your end time is in cell B2, enter the following formula in cell C2:

=B2-A2

This formula works perfectly as long as the end time is chronologically later than the start time on the same day. However, if your data includes shifts that cross over midnight, this simple subtraction will result in a negative value, causing Excel to display a series of hash marks (###) because it cannot natively display negative times under its default 1900 date system.

The MOD Formula for Overnight Spans

To calculate time duration for shifts that cross past midnight without displaying errors, use the MOD function. The MOD function returns the remainder after a number is divided by a divisor. In time tracking, dividing by 1 (which represents a full 24-hour day) corrects negative differences. Use this formula:

=MOD(B2-A2, 1)

Let us look at a worked numeric example to see how Excel processes this formula behind the scenes:

  • Start Time (Cell A2): 10:00 PM (which Excel stores as the decimal 0.916667, or 22 out of 24 hours)
  • End Time (Cell B2): 6:00 AM the next morning (stored as the decimal 0.25, or 6 out of 24 hours)
  • Substitution: =MOD(0.25 - 0.916667, 1)
  • Step 1: Subtracting the times yields -0.666667.
  • Step 2: Applying the MOD function with a divisor of 1 yields a remainder of 0.333333.
  • Result: Excel converts the decimal 0.333333 back into time format, which is exactly 8 hours (0.333333 multiplied by 24).

If you need to multiply these durations by an hourly rate to calculate payroll, you must convert the time format to a decimal value first. A complete guide on how to convert time to decimal in Excel explains how to multiply the elapsed time by 24 to get standard decimal hours.

Formatting Cells to Display Cumulative Time

Even with the correct formula, your Excel sheet may display confusing results if the cell formatting is incorrect. By default, Excel's standard "Time" format wraps around at 24 hours. If your calculation results in 26 hours of total elapsed time, Excel will display "2:00" because it drops the completed 24-hour day. To display the true, cumulative duration, you must apply a custom number format.

  1. Select the cell or column containing your duration formulas.
  2. Right-click the selected area and choose Format Cells from the context menu (or press Ctrl + 1 on Windows / Cmd + 1 on Mac).
  3. In the Category list on the left side of the window, click on Custom.
  4. In the "Type" input box, type exactly: [h]:mm:ss (or [h]:mm if you do not need to track seconds).
  5. Click OK to apply the changes.

The square brackets around the "h" are the critical instruction that tells Excel to accumulate hours continuously rather than resetting to zero at midnight. This ensures that a multi-day project phase lasting 50 hours is correctly displayed as 50:00:00 rather than 2:00:00.

Addressing Formatting Hurdles and Negative Time Errors

While Excel is a highly versatile tool, managing time formulas can quickly become tedious when dealing with mixed data, missing entries, or complex schedules. The table below compares how different Excel formulas behave under various real-world scenarios.

Calculation Scenario Excel Formula Required Formatting Behavior and Limitations
Same-day duration =B2-A2 [h]:mm Displays error if the end time is chronologically before the start time.
Overnight shift (crosses midnight) =MOD(B2-A2, 1) [h]:mm Accurately calculates differences, but is limited to spans under 24 hours.
Multi-day span (including dates) =B2-A2 [h]:mm:ss Requires you to input full dates along with times in both cells.

If your spreadsheet columns are filled with manual text entries rather than recognized time values, Excel will fail to perform any math, returning a #VALUE! error. You must convert those text blocks to true serial numbers before calculations can proceed. When these spreadsheet errors stack up, or when you are away from your main computer, using a dedicated online calculation tool is often the most practical path forward.

An Instant Alternative Using the Time Duration Calculator

For times when you want to bypass cell formatting, syntax debugging, and decimal conversions, the online Time Duration Calculator is an ideal alternative. It measures the exact amount of time between two moments. You simply enter a start date and time alongside an end date and time, and it instantly returns the elapsed span both as a human-friendly breakdown and as running totals.

Unlike Excel, there is no submit button and nothing to configure. As soon as both fields hold a valid value, the result appears and keeps updating every time you change either input, so you can experiment freely and watch the numbers respond in real time. The calculator works the way most people expect a stopwatch to work. Both the start and the end are treated as readings from the same plain wall clock, and the duration is simply the difference between them. There is no time-zone conversion and no daylight-saving adjustment, which means the result is completely predictable: pick 9:00 AM and 5:00 PM on the same day and you get exactly 8 hours, every time, no matter where you or your computer happen to be.

This makes it highly effective for timing shifts, sessions, trips, cooking, workouts, study blocks, project phases, contract periods, or any span where you want the raw elapsed time rather than a calendar-aware, time-zone-aware figure. Because the tool reports both a breakdown and totals, you never have to do the conversions by hand. If you need to know how many total minutes a two-day, three-hour gap represents, or how many seconds are in a multi-week span, those totals are shown alongside everything else.

The breakdown trims empty units for readability, so a clean one-day gap simply reads "1 day" instead of padding it with zero hours, minutes, and seconds, while a gap of exactly one hour and thirty minutes reads "1 hour, 30 minutes." Singular and plural units are handled correctly, so you will never see awkward output. Furthermore, if the end you enter falls before the start, the calculator does not error out or show a confusing negative number. Instead, it shows the absolute time between the two moments and clearly labels that the end is before the start, so a reversed pair still gives you a useful, correctly sized answer. When the start and end are identical, it reports a duration of zero seconds rather than a blank result.

Everything runs entirely inside your browser using plain JavaScript date arithmetic. No dates, times, or any other information are uploaded, logged, or sent to a server, and the tool needs no account and no network connection once the page has loaded. That makes it fast, private, and dependable even offline.

How to Calculate Time Duration Online

  1. Pick or type the start date and time in the first field.
  2. Pick or type the end date and time in the second field.
  3. Read the duration breakdown and the total days, hours, minutes and seconds, which update instantly as you edit either field.

Using this browser-based tool allows you to double-check your Excel sheet formulas, ensuring that your custom formatting and mathematical functions are outputting the correct elapsed durations without any underlying calculation errors.

If you're weighing options, How to Change Time Zone in Outlook for Meetings covers this in detail.