Skip to content

How to calculate the time difference between two times in Excel and Google Sheets

Excel & Google Sheets
=TEXT(B2-A2,"h:mm")

Verified example

Computed by a real spreadsheet engine on the sample data below.

Start TimeEnd TimeDifference
09:0017:30
08:1512:45
13:0018:00
07:3016:00

=TEXT(B2-A2,"h:mm")8:30

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Enter a start time in column A (e.g., 09:00 AM) and an end time in column B (e.g., 05:30 PM), both formatted as Time.
  2. 2In the result cell, enter =B2-A2. Format the result cell as [h]:mm (Custom format) to display hours correctly even when the difference exceeds 24 hours.
  3. 3Alternatively, use =TEXT(B2-A2,"h:mm") to return the result as a text string for display, or multiply by 24 to get decimal hours: =(B2-A2)*24.

Tips

Working on a sheet you inherited? Run the Auditor on the whole file first — it flags every #REF!, #N/A, broken column pattern, and inconsistent formula in seconds, free, no signup.

Frequently asked

How do I get the difference in minutes only?

Multiply by 1440 (minutes in a day): =(B2-A2)*1440.

Why does my result show a decimal instead of a time?

The cell is formatted as General or Number. Change the cell format to [h]:mm or use the TEXT function to control display.

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: