Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to calculate hours between times after midnight in Excel?

doc calculate time past overnight 1

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


Add a number of years / months / days / weeks / hours / minutes / seconds to date:

Kutools for Excel’s Formulas utility contains some commonly-used formulas, such as add years to date, calculate age based on birthday and so on. With these usual formulas, you can quickly get the result that you want without remembering any formulas.

doc-count-weeks-two-dates3

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


arrow blue right bubble 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:

doc calculate time past overnight 2

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:

doc calculate time past overnight 3


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    chris · 4 months ago
    Hi, i need help please. I have data that auto loads daily at 5pm. The process is broken into 2 parts (ETL1 and ETL2). ETL1 starts at 5pm till 11pm and ETL2 starts at 11 till 4 am. at 7 am i run a script to check if everything ran. each row has a start and end date time. i would like to flag all data after 5pm yesterday as todays data. Currently when i filter on today, i only see the rows where the date is after 00:00
  • To post as a guest, your comment is unpublished.
    Alan Crookes · 7 months ago
    Can someone explain when the function of addition of the TRUE/FALSE values does so I can understand the formula please?
  • To post as a guest, your comment is unpublished.
    Clifton · 8 months ago
    I think a simple MOD(B2-A2,1) should be enough?
  • To post as a guest, your comment is unpublished.
    Matt · 1 years ago
    Austin, the formula stated in the article above works well for me
  • To post as a guest, your comment is unpublished.
    Austin Bond · 1 years ago
    The formula under bullet point #1 is wrong. =(B2-A2+(B2<A2))*24, but is should read as =B2-A2+(B2<A2)*24.

    The parentheses are in the wrong spot.
    • To post as a guest, your comment is unpublished.
      NoName · 1 years ago
      THANK YOU! This is definitely the correct formula.
    • To post as a guest, your comment is unpublished.
      Axel Bak · 1 years ago
      Yes Austin! Your formula works, the other formula renders nonsense (in my case). Thanks!!
    • To post as a guest, your comment is unpublished.
      Lisa · 1 years ago
      No, Austin's correction works for me. The original with the parentheses where they are shown does not work. Maybe a diifferent version of Excel makes a difference? I am on MS Home and Office 2016
    • To post as a guest, your comment is unpublished.
      Greg · 1 years ago
      The original formula works better than your suggestion Austin.
      I also used =(A2-B2+(A2<B2))*1440
      This worked best to convert time into minutes.
      • To post as a guest, your comment is unpublished.
        Ângelo Campos · 10 months ago
        Depois de colocar a formatação ao tentar somar a coluna total de horas o valor dá-me errado.

        O campo é formatado [h]mm
        • To post as a guest, your comment is unpublished.
          fabio · 7 months ago
          =(A2-B2+(A2)) sem utilizar a multiplicação por 24