Go Back

Discover How to Make a Time Difference Calculation in Excel

Excel can calculate a time difference using the TEXT function or by subtracting the times. This step by step tutorial will assist all levels of Excel users in calculating a time difference.

Figure 1. Final result

Syntax of the TEXT formula

=TEXT(value, format_text)

The parameters of the TEXT function are:

  • value – a value which we want to format
  • format_text – a formatting which we want to apply on the value.

Setting up Our Data for the Time Difference Calculation

Our table consists of 3 columns: “Start Time” (column B), “End Time” (column C) and “Time Difference” (column D). In column D, we want to get a time difference between a start and end time.

Figure 2. Data that we will use in the time difference calculation

Time Difference Calculation Using the TEXT Function

In our example, we want to calculate the time difference between 6:19:00 PM and 3:14:30 PM and get the value in the cell D3.

Formula:

=TEXT(B3-C3,"h:mm:ss")

The value is B3-C3, which Excel calculates as a decimal number. In order to present it as a time, we need to format the value as “h:mm:ss”. This will be our format_text parameter in the function. Setting the time like this, we will get the time difference in hours, minutes and seconds.

Similarly, in the cell D4, we want to get the difference in hours and minutes, so format_text parameter will be “h:mm”. Finally, in the cell D5, we want only hours, so the format_text will be “h”.

To apply the TEXT function, we need to follow these steps:

  • In cell D3, insert the formula: =TEXT(B3-C3,"h:mm:ss")
  • Select cell D4 and click on it
  • In cell D4, insert the formula: =TEXT(B4-C4,"h:mm")
  • In cell D5, insert the formula: =TEXT(B5-C5,"h")

Figure 3. Using the TEXT function to calculate the time difference

We can see in cell D3, we get the difference 3:04:30, which is “h:mm:ss” format. In the cell D4 we get 3:04 (“h:mm”), while in the cell D5 we get the difference only in hours (3), which is “h” format.

Subtract Times to Calculate a Time Difference

Another way to calculate a time difference is to simply subtract two cells containing time values. We will use the same data set like in the previous example. Before doing the calculation, we must set the format of the resulting cell as a time. To do this, we need to press Ctrl+1, choose “Custom” category and enter the format of the time – h:mm:ss.

Figure 4. Formatting the cells for times subtraction

Formula:

B2-C2

Similarly to the previous example, in the cell D4, we want to get the difference in hours and minutes, so the format will be “h:mm”, while in the cell D5, we want only hours, so the format will be “h”.

To subtract the times, we need to follow these steps:

  • Select cell D3 and click on it
  • Press Ctrl+1
  • Choose “Custom” category and enter the format of the time – h:mm:ss
  • Insert the formula: =B3-C3
  • Press enter

  • Select cell D4 and click on it
  • Press Ctrl+1
  • Choose “Custom” category and enter the format of the time – h:mm
  • Insert the formula: =B4-C4
  • Press enter

  • Select cell D5 and click on it
  • Press Ctrl+1
  • Choose “Custom” category and enter the format of the time – h
  • Insert the formula: =B5-C5
  • Press enter

Figure 5. Subtract the times to get the times difference

As a result, we get the same times as in the previous example.

Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.

Did this post not answer your question? Get a solution from connecting with the expert.

Another blog reader asked this question today on Excelchat:
Here are some problems that our users have asked and received explanations on

iam trying to enter a calculation to determine the difference in time between two event types in a pivot table
Solved by M. H. in 16 mins
I needed help with a calculation that finds the difference between two times. I have two cells one with a start time and one with a end time which then calculates the difference and puts the total run time down below in a different cell. I use the formula =TEXT(Q5-Q4, "h:mm:ss") only issue I have is when its a night shift calculation say start time is 5:30 pm and end time is 1:20 am it can not calculate that difference. The formula does work for a day shift calculation though.
Solved by X. D. in 19 mins
I need a formulaic way of calculating differences between interest rates over time and if the difference from the starting date til the latest date exceeds 0.1, then the difference calculation needs to be updated so that the new start date becomes the latest date......needs to do this so every time the difference is greater than 0.1 the calculation updates. I'm using daily data. If the difference is less than 0.1 then the calculation keeps referencing the old start date for the subtraction
Solved by I. L. in 15 mins

Leave a Comment

avatar