Calculate the difference between two times

# Calculate the difference between two times

Let's say that you want find out how long it takes for an employee to complete an assembly line operation or a fast food order to be processed at peak hours. There are several ways to calculate the difference between two times.

## Present the result in the standard time format

There are two approaches that you can take to present the results in the standard time format (hours : minutes : seconds). You use the subtraction operator (-) to find the difference between times, and then do one of the following:

• Apply a custom format code to the cell by doing the following:

1. Select the cell.

2. On the Home tab, in the Number group, click the arrow next to the General box, and then click More Number Formats.

3. In the Format Cells dialog box, click Custom in the Category list, and then select a custom format in the Type box.

• Use the TEXT function to format the times.

When you use the time format codes, hours never exceed 24, minutes never exceed 60, and seconds never exceed 60.

### Example

The example may be easier to understand if you copy it to a blank worksheet.

How do I copy an example?

Important: Do not select the row or column headers.

Selecting an example from Help

2. Press CTRL+C.

3. In Excel, create a blank workbook or worksheet.

4. In the worksheet, select cell A1, and press CTRL+V.

Important: For the example to work properly, you must paste it into cell A1 of the worksheet.

5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

After you copy the example to a blank worksheet, you can adapt it to suit your needs.

 1 2 3 4 5 6 7 8 9
 A B Start time End time 6/9/2007 10:35 AM 6/9/2007 3:30 PM Formula Description (Result) =B2-A2 Hours between two times (4). You must manually apply the custom format "h" to the cell. =B2-A2 Hours and minutes between two times (4:55). You must manually apply the custom format "h:mm" to the cell. =B2-A2 Hours, minutes, and seconds between two times (4:55:00). You must manually apply the custom format "h:mm:ss" to the cell. =TEXT(B2-A2,"h") Hours between two times with the cell formatted as "h" by using the TEXT function (4). =TEXT(B2-A2,"h:mm") Hours and minutes between two times with the cell formatted as "h:mm" by using the TEXT function (4:55). =TEXT(B2-A2,"h:mm:ss") Hours, minutes, and seconds between two times with the cell formatted as "h:mm:ss" by using the TEXT function (4:55:00).

Note:  If you use both a format applied with the TEXT function and apply a number format to the cell, the TEXT function takes precedence over the cell formatting.

For more information about how to use these functions, see TEXT function and Display numbers as dates or times.

## Present the result based on a single time unit

To do this task, use the INT function, or the HOUR, MINUTE, and SECOND functions as shown in the following example.

### Example

The example may be easier to understand if you copy it to a blank worksheet.

How do I copy an example?

Important: Do not select the row or column headers.

Selecting an example from Help

2. Press CTRL+C.

3. In Excel, create a blank workbook or worksheet.

4. In the worksheet, select cell A1, and press CTRL+V.

Important: For the example to work properly, you must paste it into cell A1 of the worksheet.

5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.

After you copy the example to a blank worksheet, you can adapt it to suit your needs.

 1 2 3 4 5 6 7 8 9
 A B Start time End time 6/9/2007 10:35 AM 6/9/2007 3:30 PM Formula Description (Result) =INT((B2-A2)*24) Total hours between two times (4) =(B2-A2)*1440 Total minutes between two times (295) =(B2-A2)*86400 Total seconds between two times (17700) =HOUR(B2-A2) The difference in the hours unit between two times. This value cannot exceed 24 (4). =MINUTE(B2-A2) The difference in the minutes unit between two times. This value cannot exceed 60 (55). =SECOND(B2-A2) The difference in the seconds unit between two times. This value cannot exceed 60 (0).

For more information about how to use these functions, see INT function, HOUR function, MINUTE function, and SECOND function.

Connect with an expert
Explore training

×