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


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
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.
    Alan Crookes · 26 days 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 · 1 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 · 6 months ago
      THANK YOU! This is definitely the correct formula.
    • To post as a guest, your comment is unpublished.
      Axel Bak · 9 months 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 · 11 months 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 · 11 months 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 · 3 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 · 27 days ago
          =(A2-B2+(A2)) sem utilizar a multiplicação por 24