Calculate Hours Between Two Times After Midnight – 3 Methods

In the dataset below, the start time is on the present day and the end time is on the next day.


Method 1 – Use a Simple Excel Formula to Calculate Hours Between Two Times After Midnight

Steps:

  • Add a column on the right side of the dataset.

  • Go to D5 and use the following formula.
=(C5-B5)+(C5<B5)

Simple Formula with Condition to Calculate Hours between Two Times after Midnight

  • Press Enter.

The result is returned as a fraction of a day.

  • Drag down the Fill Handle to see the result in the rest of the cells.

Simple Formula with Condition to Calculate Hours between Two Times after Midnight

  • Select the whole column. Right-click.
  • Choose Format Cells in the Context Menu.

Simple Formula with Condition to Calculate Hours between Two Times after Midnight

  • In the Format Cells window, choose Time in Number.
  • Select a time format in Type.

Simple Formula with Condition to Calculate Hours between Two Times after Midnight

  • Click OK to get the result.

Read More: How to Calculate Hours Between Two Times in Excel


Method 2 – Applying the Excel IF Function to Get the Difference Between Two Times After Midnight

The IF function checks whether a condition is met and returns one value if TRUE and another value if FALSE.

Steps:

  • Enter the following formula in D5.
=IF(C5>B5,C5-B5,1-B5+C5)

IF Function calculate hours between two times in Excel

  • Press Enter.

The result is displayed in the selected time format.

  • Drag down the Fill Handle to see the result in the rest of the cells.

IF Function calculate hours between two times in Excel

This formula compares the start and the end times. If the end time is greater than the start time, it subtracts the start time from the end time. Otherwise, it subtracts the start time from 1 and adds the end time.


Method 3 – Applying the Excel MOD Function

The MOD function returns the remainder after a number is divided by a divisor.

Steps:

  • Enter this formula in D5.
=MOD(C5-B5,1)

Excel MOD Function to calculate hours

  • Press Enter.
  • Drag down the Fill Handle to see the result in the rest of the cells.

 


Download Practice Workbook

Download the practice workbook.


Related Articles


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

Get FREE Advanced Excel Exercises with Solutions!
Alok Paul
Alok Paul

Alok Paul has completed his B.Sc. in Electronics and Telecommunication Engineering from East West University. He has been working on the ExcelDemy project for more than 2 years. He has written 220+ articles and replied to numerous comments. He is experienced in Microsoft Office, especially in Excel. He also led some teams on Excel and VBA content development. He has a keen interest in Advanced Excel, Data analysis, Excel Pivot Table, Charts, and Dashboard. He loves to research... Read Full Bio

2 Comments
  1. Thank you very much it is helpful

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo