## How to calculate hours between times after midnight in Excel?

Supposing you have a time table to record your work time, the time in Column A is the start time of today and time in Column B is the end time of the following day. Normally, if you calculate the time difference between the two times by directly minus "=B2-A2", it will not display the correct result as left screenshot shown. How could you calculate the hours between two times after midnight in Excel correctly?

Calculate hours between two times after midnight with formula

#### Calculate hours between two times after midnight with formula

To get the correct calculated result between two times over midnight, you can apply the following formula:

1. Enter this formula: =(B2-A2+(B2<A2))*24 (A2 is the earlier time, B2 is the later time, you can change them as you need) into a blank cell which beside your time data, see screenshot:

2. Then drag the fill handle to the cells that you want to fill this formula, and the time differences between two times after midnight have been calculated at once, see screenshot:

### Unlock Excel Magic with Kutools AI

• Smart Execution: Perform cell operations, analyze data, and create charts—all driven by simple commands.
• Custom Formulas: Generate tailored formulas to streamline your workflows.
• VBA Coding: Write and implement VBA code effortlessly.
• Formula Interpretation: Understand complex formulas with ease.