How to Calculate Time Difference Between Two Times in Excel

- Written by Puneet Gogia

If you work with data that has time values, then the tips I’m going to share today can be helpful for you. Now listen.

In Excel, there are a lot of functions that deal with date and time. But there is no specific function that you can use to get the difference between times values.

As you know, a time value is a numeric value formatted as time. However, when you deduct one value from another, it returns a decimal number, which you need to format again as time.

But here comes the pain:

When you format that result value, it shows those values as hours and minutes (starting from 00:00) instead of the actual difference in hours and minutes.

So, if you have a difference of 5 hours and 30 minutes, it will show as 05:00 AM. You don’t have to worry anymore.

1. Get the Difference in Hours and Minutes

This is one of the most common ways to calculate the difference between two times. Let’s suppose you have a start and end time (like below) and need to calculate the difference between both.

calculate time difference from start end
  1. First of all, you can simply deduct the end time from the start time and you’ll get something like below.
    calculate time difference deduct start end
  2. Now next you need to convert this time into hours and minutes.
  3. For this, select the cell and open format options (Ctrl + 1).
  4. After that, select the “Time” category and select the second time format.
    calculate time difference format into hour and minutes
  5. In the end, click OK.
    calculate time difference hours minutes

Once you do this, it will convert (Format) that time difference into hours and minutes instead of the normal time format.

2. Get Different in Hours in Numbers

This is not a common way to calculate a time difference, but it is still useful and important. Let’s say you want to calculate the difference between start and end time in hours but not in normal numbers.

For example, if the difference between the start and end time is 4 hours and 30 minutes, it should show it as 4.5 hours. Here’s the formula that you need to use.

=(end_time-start_time)*24
calculate time difference in hours numbers

Once you enter this formula, it returns the hours in numbers and minutes (if you have them) in decimals.

How this Formula Works

As I said before, Excel stores date and time in numbers, and when you deduct the end time from the start time it returns a decimal. When you multiply it by 24 (the total number of hours in a day), it converts that decimal into the number of hours and minutes.

3. Get Different in Completed Hours

You can also calculate the completed hours between two times with this simple formula.

=INT((end_time-start_time)*24)

calculate time difference complete hours

How this Formula Works

This formula is just like the formula which we have used in the second method, the only difference is here we have wrapped it in INT.

INT function returns the integer part decimal by rounding it down. You can learn more about it here. So when you enter this formula, first of all, it returns a decimal number for the hours, and then INT removes the fractional part and gives you completed hours.

4. Get Difference in Minutes

It happens sometimes that you need to track the time difference in minutes instead of hours, and in this case, the best way is to use the below formula.

=(end_time-start_time)*1440
calculate time difference in minutes

In this formula, after deducting the start time from the end time we have multiplied it by 1440 which is the total number of minutes we have in 24 hours. And when you enter this formula you’ll get the difference between two values in minutes.

Quick Tip: If somehow you have seconds in your time values then you use the below formula to get the total complete minutes between start and end time.

5. Get Difference in Seconds

Same as minutes we can also get the difference in seconds. All you need to do is to use the following formula.

=(end_time-start_time)*86400
calculate time difference in seconds

Here 86400 is the total second in 24 hours and when you enter this formula it will return the difference in start and end time in seconds.

6. Calculate the Difference as a Negative Value

In all the above examples, we have the end time which is greater than (later than) the start time.

Let’s suppose you have two time values where the end time is earlier than the start time. In simple words, if the start time is 11:00 PM on day 1, and the end time is 5:00 AM on day 2.

The end time is actually less than the start time and the simple subtract formula will not work and return a negative value which will cause Excel to display a string of hash characters (i.e. ########).

calculate time difference error

Don’t worry you can use a better formula for this. So the formula will be:

=IF(end>start, end-start, 1-start+end)

calculate time difference negative value

How this Formula Works

In this formula, you have a condition if the end time is greater than the start time then it will simply deduct the end time from the start time otherwise, firstly it will deduct the start time from 1 and then add it to the end time.

By subtracting the start time from 1, you will get the total time for day 1 and when you add it to the end time, you’ll get the total time of day 1 and day 2 which is the total difference.

Get the Excel File

Conclusion

For Excel users who deal with time data, it’s really important to know various methods to get the difference between two times.

And all the methods which we have used above can be used in different situations and I’m sure you have found all of these helpful.

But you need to tell me one thing.

Do you know any other method which you can use to get the difference between the start time and end time?

Share your views with me in the comment section, I’d love to hear from you, and make sure to share this tip with your friends.

29 thoughts on “How to Calculate Time Difference Between Two Times in Excel”

  1. Hi all

    great article but I’m still struggling with one aspect of this and can’t make it work in one particular use case. For most of the time calculations I’ve tried it on, it’s perfect but when I try to find previous time, I can’t get the formula to comply.

    For example, if I put 16:40-(5.5/24) to get 5.5 hours prior to the time on the left (16:40) – I correctly get 11:10. However, if I apply the same formula to the time of 04:05am [04:05-(5.5/24)] it gives me an error instead of the expected result of 22:35 (i.e. 5.5 hours earlier the day before).

    Does anyone have any ideas on what I’m doing wrong? Thanks and much appreciative of any help provided.

    Reply
    • With time, you are actually still dealing with dates as well. This means both 16:40 and 04:05 actually get stored as a serial number which ends up being 00/01/1900 16:40 and 00/01/1900 04:05 – you’ll see that if you update the cell format to dd/mm/yy hh:mm format (or other date format you might choose).
      It’s just that Excel has sensed you entered a time so defaults to displaying just the time portion of the actual cell value – ie in hh:mm format.
      Hence subtracting more then 4 hours and 5 mins from the time in the second example results in a date that is impossible for Excel, 1st Jan 1900 being the earliest date it works with.
      ..
      One way round this could be to add 1 day to the time as it would not affect the time displayed *but* it would mean sorting time field would go weird.
      ..
      Hope this help explain the issue.
      ……..
      PS: The one thing I haven’t been able to explain to myself for a long time .. why does it handle day 0 of the first yr & mth it ‘can’ handle. I have no answer for that. Just knowing that the numeric (‘serial’) value “0” equates to a start date-time stamp means there’ll be a problem if I try to go negative.

      Reply
  2. THNK YOU!! I have been scouring the net trying to find out how to calculate two times as a number In Excel!!! You’re a lifesaver!

    Reply
  3. The above method has helped me no other that i know
    Thanks

    Reply
  4. Thank you for your explanations, in 6. Calculate Difference as a Negative Value, you use two time dates. How would you do a negative if I want to do a negative dollar amount divided by a positive time amount.
    eg: I trade the market and make $100 profit in 2.00 Hours = $50.00 P/Hour
    I trade the market and lose $100 in 2.0 Hours = ##############
    How can I fix this?

    Reply
  5. Do you know how to calculate the difference in a given start date and end date when you want to exempt weekends and certain holidays except not by using the NETWORKDAYS function?

    Reply

Leave a Comment