How to Calculate Hours Between Two Times in Excel (6 Methods)

 

Method 1 – Calculating Hours Between Two Times by Subtracting Them in Excel

We’ve created the following data table to calculate the hours between two times in Excel. The table consists of 3 columns. The first column contains the starting time, the second column contains the ending time, and the third column contains the total hours.

Basic Dataset

Steps:

  • Insert the following formula in cell D5:
=C5-B5
  • Press the Enter key.
  • Drag the Fill Handle icon to the end of the Total Hours column.

Calculate Hours Simply by Subtracting Two times in Excel


Method 2 – Using the HOUR Function to Compute Hours Between Two Times in Excel

Steps:

  • Select cell D5 to insert the following formula:
=HOUR(C5-B5)
  • Hit Enter.
  • Drag the Fill Handle icon to the end of the Total Hours column.

Use HOUR Function to Compute Hours Between Two Times in Excel


Method 3 – Using the TEXT Function to Calculate Hours Between Two Times in Excel

Steps:

  • Input the following formula in cell D5:
=TEXT(C5-B5, "h")
  • Press Enter.
  • Drag the Fill Handle icon to the end of the Total Hours column.

Method 4 – Calculating Hours Between Two Different Dates in Excel

Steps:

  • Insert the formula below within cell D5.
=INT((C5-B5)*24)
  • Hit Enter and drag the Fill Handle icon to the end of the third column of the data table.

Note: The number format of the result column has to be General.

Calculate Hours Between Two Different Dates in Excel


Method 5 – Using the IF Function to Calculate Hours Between Two Times in Excel

This method eliminates negative values by always subtracting the earlier time from the later one.

Steps:

  • Insert the formula below in cell D5.
=IF(C5>B5,C5-B5,1-B5+C5)
  • Press Enter and drag the Fill Handle icon to the end of the Total Hours column.


Method 6 – Counting Elapsed Time in Hours from a Starting Time to Now

Steps:

  • Enter the following formula in cell D5.
=TIME(HOUR(NOW()),MINUTE(NOW()),SECOND(NOW())) -B5
  • Hit Enter.
  • Drag the Fill Handle icon to the end of the Total Hours column.

Formula Breakdown

  • HOUR(NOW() ▶ returns the current hour of time.
  • MINUTE(NOW() ▶ returns the present minute.
  • SECOND(NOW() ▶ returns the current second of time.
  • TIME(HOUR(NOW()),MINUTE(NOW()),SECOND(NOW())) ▶ constitutes standard time formula of the current time.

Read More: Excel Calculate Hours Between Two Times After Midnight


Things to Remember

If a cell doesn’t have enough space to show the entire time value, Excel returns ####. Adjust the cell width to fix the issue.


Download the Practice Workbook

Download the Excel file and practice along with it.


Related Articles


<< Go Back to Calculate Hours | Calculate Time | Date-Time in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Mrinmoy Roy
Mrinmoy Roy

Mrinmoy Roy, a dedicated professional with a BSc in Electronics and Communication Engineering from Khulna University of Engineering & Technology, Bangladesh, brings over two years of expertise to the ExcelDemy project. As a prolific contributor, he has authored around 180 articles, showcasing his deep knowledge and passion for Microsoft Excel, Data Analysis, and VBA. His unwavering commitment to continuous learning, combined with versatile skills, renders him well-suited for roles in data management and spreadsheet solutions. He has interest... Read Full Bio

2 Comments
  1. Reply
    michael gamal aziz Mar 15, 2023 at 1:29 PM

    thankssssssssssss

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo