Excel Duration Formula: How to Calculate Time Elapsed
In this article
To calculate duration in Excel, subtract the start time (or date) from the end time (or date) using a simple subtraction formula: =End_Time - Start_Time. Because Excel stores dates as whole numbers and times as decimals, this subtraction provides the difference between two points in time, which you can then format to display as hours, minutes, or days.
What You'll Need
- Microsoft Excel (any modern version)
- A dataset containing at least two columns: a start time/date and an end time/date
- Basic knowledge of how to select cells and enter a formula
Step-by-Step
- Input Your Data: Enter your start times in one column (e.g., Column A) and your end times in another (e.g., Column B). For the best results, ensure you use a consistent format, such as
HH:MM AM/PMorYYYY-MM-DD HH:MM. - Enter the Basic Formula: Click on the cell where you want the duration to appear (e.g., Cell C2). Type the equals sign
=, click the cell containing the end time (B2), type a minus sign-, and then click the cell containing the start time (A2). Your formula should look like=B2-A2. Press Enter. - Apply the Correct Number Format: By default, Excel may display the result as a decimal or a date, which looks incorrect. To fix this, right-click the result cell and select Format Cells. In the Number tab, choose Time and pick the format that suits your needs (e.g., 13:30).
- Handle Durations Over 24 Hours: If your duration exceeds 24 hours, Excel's standard time format will "reset" to zero (e.g., 25 hours will show as 1 hour). To prevent this, go back to Format Cells, select Custom, and in the Type box, manually enter
[h]:mm:ss. The square brackets tell Excel to accumulate hours rather than rolling them over into a new day. - Calculate Duration in Minutes or Seconds: If you need the result as a raw number of minutes rather than a time format, multiply the subtraction result by the number of minutes in a day. Use the formula
=(B2-A2)*1440(since 24 hours * 60 minutes = 1440). Change the cell format to General or Number to see the total minutes. - Calculate Duration in Seconds: Similarly, to get the total seconds, multiply the subtraction by 86,400 (24 hours * 60 minutes * 60 seconds). Use the formula
=(B2-A2)*86400and set the cell format to General. - Use the TEXT Function for Custom Labels: If you want the result to read as a sentence (e.g., "Duration: 5 hours"), use the TEXT function. Enter
="Duration: " & TEXT(B2-A2, "[h] \"hours\" m \"minutes\""). This converts the numeric value into a formatted string of text. - Calculate Duration Across Multiple Days: If your start and end points span different dates, you must include the date in the cell. Enter data as
MM/DD/YYYY HH:MM. The subtraction formula=B2-A2still works, but you must use the[h]:mmcustom format to see the total hours across those days.
Common Mistakes
One of the most frequent errors is subtracting the end time from the start time (=A2-B2). This results in a negative time value. Because Excel cannot display negative times by default, the cell will fill with a series of hashtags (#######), which is known as a "fence" error. Always ensure the later time comes first in your formula.
Another common mistake is ignoring the cell format. Users often see a decimal like 0.25 and assume the formula is broken. In Excel's internal logic, 0.25 represents one-quarter of a day, which is 6 hours. The formula is working correctly; the cell simply needs to be formatted as Time.
Many users also forget to use the square brackets [h] in custom formatting. Without these brackets, Excel treats the time as a "time of day" (clock time) rather than a "duration of time" (elapsed time). If a project took 30 hours, a standard format will show 6:00 (30 minus 24), which leads to significant reporting errors.
Tips
To make your spreadsheets more dynamic, use the NOW() function to calculate duration in real-time. For example, if you have a start time in A2, the formula =NOW()-A2 will show exactly how much time has elapsed from that start point to the current moment. Note that this value only updates when the worksheet recalculates (e.g., when you enter data or press F9).
For complex project tracking, consider using the NETWORKDAYS function. Standard subtraction counts every single hour and day, including weekends. If you only want to calculate the duration of work hours, NETWORKDAYS can help you find the number of working days between two dates, which you can then multiply by your daily shift hours.
If you are dealing with very large datasets, use an Excel Table (Ctrl+T). When you enter the duration formula in the first row of a table, Excel will automatically fill the formula down the entire column, ensuring consistency and saving time as you add new entries.
Troubleshooting
If your result is showing as a series of hashtags (#######), first check if your result is negative. If the start time is later than the end time, the formula will fail. If the result is positive but still shows hashtags, the column may simply be too narrow to display the formatted time; widen the column by double-clicking the border of the column header.
If the duration seems wildly inaccurate (e.g., showing thousands of hours), check the data types of your input cells. If one cell is formatted as Text and the other as Time, Excel may struggle to perform the math or may treat the text as a zero value. Use the Value function or the Text to Columns tool to convert text-based dates into actual Excel date serial numbers.
If the formula =B2-A2 returns a value that doesn't change when you update the times, check your Calculation Options. Go to the Formulas tab, click Calculation Options, and ensure Automatic is selected. If it is set to Manual, formulas will not update until you manually trigger a recalculation.
Frequently Asked Questions
Why does my time reset after 24 hours?
Excel defaults to a clock-face format. To show elapsed time beyond 24 hours, you must use the Custom Format [h]:mm:ss. The brackets tell Excel to keep counting hours instead of starting over at midnight.
How do I calculate duration excluding weekends?
Use the NETWORKDAYS(start_date, end_date) function to get the number of working days. To get the exact hours, you would subtract the start time from the end time on the first and last days and add the full working hours for the days in between.
Can I calculate duration between two different dates?
Yes. As long as the cells contain both the date and the time (e.g., 2023-10-01 08:00), the subtraction formula =End-Start will work perfectly. Just remember to use the [h] custom format to see the total hours.
What is the difference between Time and Duration in Excel?
Time refers to a specific point in the day (e.g., 2:00 PM), while Duration refers to the amount of time that has passed (e.g., 2 hours). While they look similar, Duration requires the [h] format to avoid resetting every 24 hours.
How do I convert a duration result into a decimal number?
Since Excel stores one day as the number 1, multiply your duration result by 24 to get the total hours as a decimal (e.g., 1.5 hours instead of 1:30). Ensure the cell format is set to Number or General.