Calculate the difference between two times

Microsoft Office Excel 2003

Use the subtraction operator (-) to find the difference between times, and the TEXT function to format the times.

Hours never exceed 24, minutes never exceed 60, and seconds never exceed 60.

Worksheet example

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

ShowHow?

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic. Do not select the row or column headers.

    Selecting an example from Help

    Selecting an example from Help

  3. Press CTRL+C.
  4. In the worksheet, select cell A1, and press CTRL+V.
  5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and then click Formula Auditing Mode.
 
1
2
A B
Start time End time
6/9/2007 10:35 AM 6/9/2007 3:30 PM
Formula Description (Result)
=TEXT(B2-A2,"h") Hours between two times (4)
=TEXT(B2-A2,"h:mm") Hours and minutes between two times (4:55)
=TEXT(B2-A2,"h:mm:ss") Hours and seconds between two times (4:55:00)

Note  You can also apply the time and date number format without using the TEXT function to specify the format. However, if you use both a format applied with the TEXT function and number format, the TEXT function takes precedence.

Function details

TEXT

ShowFor presenting the result in a total based on one time unit (120 minutes)

Use the INT function, or HOUR, MINUTE, and SECOND functions to do this task.

Worksheet example

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

Show How?

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic. Do not select the row or column headers.

    Selecting an example from Help

    Selecting an example from Help

  3. Press CTRL+C.
  4. In the worksheet, select cell A1, and press CTRL+V.
  5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and then click Formula Auditing Mode.
 
1
2
A B
Start time End time
6/9/2007 10:35 AM 6/10/2007 3:30 PM
Formula Description (Result)
=INT((B2-A2)*24) Total hours between two times (28)
=(B2-A2)*1440 Total minutes between two times (1735)
=(B2-A2)*86400 Total seconds between two times (104100)
=HOUR(B2-A2) Hours between two times, when the difference does not exceed 24. (4)
=MINUTE(B2-A2) Minutes between two times, when the difference does not exceed 60. (55)
=SECOND(B2-A2) Seconds between two times, when the difference does not exceed 60. (0)

Function details

INT

HOUR

MINUTE

SECOND