How to calculate time in Excel - time difference, adding / subtracting times

This tutorial focuses on various ways to calculate times in Excel. You will find a few useful formulas to add and subtract times, calculate time difference, or elapsed time, and more.

In the last week's article, we had a close look at the specificities of Excel time format and capabilities of basic time functions. Today, we are going to dive deeper into Excel time calculations and you will learn a few more formulas to efficiently manipulate times in your worksheets.

How to calculate time difference in Excel (elapsed time)

To begin with, let's see how you can quickly calculate elapsed time in Excel, i.e. find the difference between a beginning time and an ending time. And as is often the case, there is more than one formula to perform time calculations. Which one to choose depends on your dataset and exactly what result you are trying to achieve. So, let's run through all methods, one at a time.

Add and subtract time in Excel with a special tool

No muss, no fuss, only ready-made formulas for you
Date & Time Formula Wizard for Excel Read more

Easily find difference between two dates in Excel

Get the result as a ready-made formula in years, months, weeks, or days
Date & Time Formula Wizard for Excel Read more

Calculate age in Excel on the fly

And get a custom-tailored formula
Date & Time Formula Wizard for Excel Read more

Formula 1. Subtract one time from the other

As you probably know, times in Excel are usual decimal numbers formatted to look like times. And because they are numbers, you can add and subtract times just as any other numerical values.

The simplest and most obvious Excel formula to calculate time difference is this:

=End time - Start time

Depending on you data structure, the actual time difference formula may take various shapes, for example:

Formula Explanation
=A2-B2 Calculates the difference between the time values in cells A2 and B2.
=TIMEVALUE("8:30 PM") - TIMEVALUE("6:40 AM") Calculates the difference between the specified times.
=TIME(HOUR(A2), MINUTE(A2), SECOND(A2)) - TIME(HOUR(B2), MINUTE(B2), SECOND(B2)) Calculates the time difference between values in cells A2 and B2 ignoring the date difference, when the cells contain both the date and time values.

Remembering that in the internal Excel system, times are represented by fractional parts of decimal numbers, you are likely to get the results similar to this:
Calculating time difference in Excel

The decimals in column D are perfectly true but not very meaningful. To make them more informative, you can apply custom time formatting with one of the following codes:

Time code Explanation
h Elapsed hours, display as 4.
h:mm Elapsed hours and minutes, display as 4:10.
h:mm:ss Elapsed hours, minutes and seconds, display as 4:10:20.

To apply the custom time format, click Ctrl + 1 to open the Format Cells dialog, select Custom from the Category list and type the time codes in the Type box. Please see Creating a custom time format in Excel for the detailed steps.

And now, let's see how our time difference formula and time codes work in real worksheets. With Start times residing in column A and End times in column B, you can copy the following formula in columns C though E:


The elapsed time is displayed differently depending on the time format applied to the column:
The elapsed time is displayed differently depending on the applied time format.

Note. If the elapsed time is displayed as hash marks (#####), then either a cell with the formula is not wide enough to fit the time or the result of your time calculations is a negative value.

Formula 2. Calculating time difference with the TEXT function

Another simple technique to calculate the duration between two times in Excel is using the TEXT function:

  • Calculate hours between two times: =TEXT(B2-A2, "h")
  • Return hours and minutes between 2 times: =TEXT(B2-A2, "h:mm")
  • Return hours, minutes and seconds between 2 times: =TEXT(B2-A2, "h:mm:ss")

Calculating time difference with TEXT function


  • The value returned by the TEXT function is always text. Please notice the left alignment of text values in columns C:E in the screenshot above. In certain scenarios, this might be a significant limitation because you won't be able to use the returned "text times" in other calculations.
  • If the result is a negative number, the TEXT formula returns the #VALUE! error.

Formula 3. Count hours, minutes or seconds between two times

To get the time difference in a single time unit (hours ,minutes or seconds), you can perform the following calculations.

Calculate hours between two times:

To present the difference between two times as a decimal number, use this formula:

=(End time - Start time) * 24

Supposing that your start time is in A2 and end time in B2, you can use a simple equation B2-A2 to calculate the difference between two times, and then multiply it by 24, which is the number of hours in one day:

=(B2-A2) * 24

To get the number of complete hours, use the INT function to round the result down to the nearest integer:

=INT((B2-A2) * 24)
Calculating hours between two times in Excel

Total minutes between two times:

To calculate the minutes between two times, multiply the time difference by 1440, which is the number of minutes in one day (24 hours * 60 minutes = 1440).

=(End time - Start time) * 1440

As demonstrated in the following screenshot, the formula can return both positive and negative values, the latter occur when the end time is less than the start time, like in row 5:

Calculating total minutes between two times in Excel

Total seconds between times:

To get the total seconds between two times, you multiply the time difference by 86400, which is the number of seconds in one day (24 hours * 60 minutes * 60 seconds = 86400).

=(End time - Start time) * 86400

In our example, the formula is as follows:

=(B2-A2)* 86400
Calculating total seconds between two times

Note. For the results to display correctly, the General format should be applied to the cells with your time difference formula.

Formula 4. Calculate difference in one time unit ignoring others

To find the difference between 2 times in a certain time unit, ignoring the others, use one of the following functions.

  • Difference in hours, ignoring minutes and seconds:


  • Difference in minutes, ignoring hours and seconds:


  • Difference in seconds, ignoring hours and minutes:


When using Excel's HOUR, MINUTE and SECOND functions, please remember that the result cannot exceed 24 for hours and 60 for minutes and seconds.
Calculate time difference in one unit ignoring others

Note. If the end time is less than the start time (i.e. the result of the formula is a negative number), the #NUM! error is returned.

Formula 5. Calculate elapsed time from a start time to now

In order to calculate how much time has elapsed since the start time to now, you simply use the NOW function to return today's date and the current time, and then subtract the start date and time from it.

Supposing that the beginning date and time is in call A2, the formula =NOW()-A2 returns the following results, provided you've applied an appropriate time format to column B, h:mm in this example:
Calculating elapsed time from a start time to now

In case the elapsed time exceeds 24 hours, use one of these time formats, for example d "days" h:mm:ss like in the following screenshot:
Calculating elapsed time over 24 hours

If your starting points contain only time values without dates, you need to use the TIME function to calculate the elapsed time correctly. For example, the following formula returns the time elapsed since the time value in cell A2 up to now:

Calculating elapsed time without dates

Note. The elapsed time is not updated in real-time, it refreshes only when the workbook is reopened or recalculated. To force the formula to update, press either Shift + F9 to recalculate the active spreadsheet or hit F9 to recalculate all open workbooks.

Formula 5. Display time difference as "XX days, XX hours, XX minutes and XX seconds"

This is probably the most user-friendly formula to calculate time difference in Excel. You use the HOUR, MINUTE and SECOND functions to return corresponding time units and the INT function to compute the difference in days. And then, you concatenate all these functions in a single formula along with the text labels:

=INT(B2-A2) & " days, " & HOUR(B2-A2) & " hours, " & MINUTE(B2-A2) & " minutes and " & SECOND(B2-A2) & " seconds"
A user-friendly Excel time difference formula

To instruct your Excel time difference formula to hide zero values, embed four IF functions into it:

=IF(INT(B2-A2)>0, INT(B2-A2) & " days, ","") & IF(HOUR(B2-A2)>0, HOUR(B2-A2) & " hours, ","") & IF(MINUTE(B2-A2)>0, MINUTE(B2-A2) & " minutes and ","") & IF(SECOND(B2-A2)>0, SECOND(B2-A2) & " seconds","")

The syntax may seem excessively complicated, but it works :)

Excel time difference formula that ignores zero values

Alternatively, you can calculate time difference by simply subtracting the start time from the end time (e.g. =B2-A2), and then apply the following time format to the cell:

d "days," h "hours," m "minutes and" s "seconds"
Subtract the start time from the end time and apply the custom time format to the cell.

An advantage of this approach is that your result would be a normal time value that you could use in other time calculations, while the result of the complex formula discussed above is a text value. A drawback is that the custom time format cannot distinguish between zero and non-zero values and ignore the latter. To display the result in other formats, please see Custom formats for time intervals over 24 hours.

How to calculate and display negative times in Excel

When calculating the time difference in Excel, you may sometimes get the result as ###### error because the difference is a negative time. But is there a way to show negative times properly in Excel? Of course, there is a way, and even more than one :)

Method 1. Change Excel Date System to 1904 date system

The fastest and easiest way to display negative time normally (with a minus sign) is switching to the 1904 date system. To do this, click File > Options > Advanced, scroll down to the When calculating this workbook section and put a tick in the Use 1904 date system box.
Changing to the 1904 data system

Click OK to save the new settings, and from now on negative times will be displayed correctly, like negative numbers:
In the 1904 date system, negative times are displayed like negative numbers

Method 2. Calculate negative time in Excel with formulas

Is changing Excel's default Date System is not an option, then you can force negative times to display properly using one of the following formulas:

=IF(A2-B2>0, A2-B2, "-" & TEXT(ABS(A2-B2),"h:mm"))

=IF(A2-B2>0, A2-B2, TEXT(ABS(A2-B2),"-h:mm"))

Both formulas check if the time difference (A2-B2) is greater than 0, and if it is they return that difference. If the time difference is less than zero, the first formula calculates the absolute difference and concatenates the minus sign. The second formula yields exactly the same result by using a negative time format "-h::mm".
A formula to calculate negative times in Excel

Note. Please keep in mind that unlike the first method that treats negative times as negative numeric values, the result of the TEXT function is always a text string that cannot be used in calculations or other formulas.

Adding and subtracting time in Excel

Basically, there are 2 ways to add and subtract time in Excel:

  • Using the TIME function
  • Using arithmetic calculations based on the number of hours (24), minutes (1440) and seconds (86400) in one day

The TIME(hour, minute, second) function makes Excel time calculations really easy, however it does not allow adding or subtracting more than 23 hours, or 59 minutes, or 59 seconds. If you are working with bigger time intervals, then use one of the arithmetic calculations demonstrated below.

How to add or subtract hours to time in Excel

To add hours to a given time in Excel, you can use one the following formulas.

TIME function to add under 24 hours

=Start time + TIME(N hours, 0, 0)

For example, if your start time is in cell A2, and you want to add 2 hours to it, the formula is as follows:

=A2 + TIME(2, 0, 0)
TIME function to add under 24 hours

Note. If you try adding more than 23 hours with the TIME function, the specified hours will be divided by 24 and the remainder will be added to the start time value. For example, if you try to add 25 hours to "6/2/2015 10:00 AM" (cell A4) using the formula =A4 + TIME(25, 0, 0), the result will be "06/02/2015 11:00", i.e. A4 + 1 hour.

Formula to add any number of hours (under or over 24 hours)

The following formula has no limitations to the number of hours you want to add:

= Start time + (N hours / 24)

For example, to add 28 hours to the start time in cell A2, enter the following formula:

=A2 + (28/24)

Universal formula to add hours to a given time in Excel

To subtract hours from a given time, you use analogous formulas, and just replace "+" with the minus sign:

For example, to subtract 3 hours from the time in cell A2, either of the following formulas will do:



To subtract more than 23 hours, use the first one.

How to add / subtract minutes to time in Excel

To add minutes to a given time, employ the same techniques that we've just used for adding hours.

To add or subtract under 60 minutes

Use the TIME function and supply the minutes you want to add or subtract in the second argument:

=Start time + TIME(0, N minutes, 0)

And here are a couple of real-life formulas to calculate minutes in Excel:

To add 20 minutes to the time in A2: =A2 + TIME(0,20,0)

To subtract 30 minutes from the time in A2: =A2 - TIME(0,30,0)

To add or subtract over 60 minutes

In your calculation, divide the number of minutes by 1440, which is the number of minutes in a day, and add the quotient to the start time:

=Start time + (N minutes / 1440)

To subtract minutes from time, simply replace plus with the minus sign. For example:

To add 200 minutes: =A2 + (200/1440)

To subtract 300 minutes: =A2 -(300/1440)

Adding and subtracting minutes in Excel

How to add / subtract seconds to a given time

Second calculations in Excel are done in a similar fashion.

To add under 60 seconds to a given time, you can use the TIME function:

=Start time + TIME(0, 0, N seconds)

To add more than 59 seconds, use the following formula:

=Start time + (N seconds / 86400)

To subtract seconds, utilize the same formulas with the minus sign (-) instead of plus (+).

In your Excel worksheets, the formulas may look similar to these:

To add 30 seconds to A2: =A2 + TIME(0,0,31)

To add 1200 seconds to A2: =A2 + (1200/86400)

To subtract 40 seconds from A2: =A2 - TIME(0,0,40)

To subtract 900 seconds from A2: =A2 - (900/86400)

How to sum time in Excel

The Excel sum time formula is the usual SUM function, and applying the proper time format to the result is what does the trick.

Supposing you have a few project times in column B and you want to add them up. You write a simple SUM formula like =SUM(B2:B4) and get the result in the default format, like hh:mm:ss.
A SUM formula to add up times in Excel

In some cases the default time format works just fine, but sometimes you may want more, for example to display the total time as minutes and seconds, or seconds only. The good news is that no other calculations are required, all you have to do is apply custom time format to the cell with the SUM formula.

Right click the cell and select Format Cells in the context menu, or press Ctrl + 1 to open the Format Cells dialog box. Select Custom from the Category list and type one of the following time formats in the Type box:

  • To display total time as minutes and seconds: [m]:ss
  • To display total time as seconds: [ss]

The result will look as follows:
Apply the custom time format to display total time as minutes and seconds, or seconds only.

How to sum over 24 hours in Excel

In order to add up more than 24 hours, you use the same SUM formula as discussed above, and apply one of the following time formats to the cell:

Format Displays as Explanation
[h]:mm 30:10 Hours and minutes
[h]:mm:ss 30:10:20 Hours, minutes and seconds
[h] "hours", mm "minutes", ss "seconds" 30 hours, 10 minutes, 20 seconds
d h:mm:ss 1 06:10:20 Days, hours, minutes and seconds
d "day" h:mm:ss 1 day 06:10:20
d "day," h "hours," m "minutes and" s "seconds" 1 day, 6 hours, 10 minutes and 20 seconds

To see how these custom time formats may look like in your Excel worksheet, please have a look at the screenshot below, where the same SUM formula is entered in cells A9 to A13:


Adding up more than 24 hours in Excel

Note. The above custom time formats work for positive values only. If the result of your time calculations is a negative number, e.g. when you are subtracting a bigger time from a smaller time, the result will be displayed as #####. To display negative times differently, please see custom format for negative time values.

Also, please keep in mind that the time format applied to a cell changes only the display presentation without changing the cell's value. For example, in the screenshot above, cell A13 looks like text, but in fact it's a usual time value, which is stored as a decimal in the internal Excel system. Meaning, you are free to refer to that cell in other formulas and calculations.

To have a closer look at the time formulas discussed in this article, feel free to download our Sample Workbook with Time Calculations.

Date & Time Formula Wizard - quick way to calculate times in Excel

Now that you know a bunch of different formulas to add and subtract times in Excel, let me show you the tool that can do it all. Okay, almost all :)

Here comes Ablebit's Date & Time Formula Wizard for Excel:
Date & Time Formula Wizard for Excel

In the Date & Time Wizard dialog window, you switch to the Add or Subtract tab, depending on which operation you want to perform, and do the following:

  • Click the Show time fields link in the left part of the window.
  • Supply values or cell references for the formula arguments. As you fill in the argument boxes, the wizard builds the formula in the selected cell.
  • When finished, click the Insert Formula

That's it! For example, this is how you can add the specified number of hours, minutes and seconds to the time in A4:
Add hours, minutes and seconds to the original time in Excel

If you need to copy the formula to other cells, fix all references except the cell containing the original time (A4) with the $ sign like shown in the screenshot below (by default, the wizard always uses relative references). Then double-click the fill handle to copy the formula down the column and you are good to go!
Formula to add hours, minutes and seconds to time in Excel

Besides time calculations, the wizard can also add and subtract dates, get the difference between two dates, and calculate age from the birthdate.

If you are curious to try this tool in your own worksheets, you are welcome to download the 14-day trial version of our Ultimate Suite which includes this as well as 60 more time saving add-ins for Excel.

This is how you calculate time in Excel worksheets. To learn other ways to manipulate dates and times in Excel, I encourage you to check out the resources at the end of this article. I thank you for reading and hope to see you on our blog next week!

Excel Date and Time tutorials:

498 Responses to "How to calculate time in Excel - time difference, adding / subtracting times"

  1. Patrick Rudolph says:

    I need to make a cell (minutes late) using 1 cell (Scheduled departure time) being subtracted from another cell (actual departure time). The trick is i need the time starting at 12:00 pm. Ex: Truck leaves at 12:15 am, but the Scheduled time is 11:45 pm. My current sheet shows 23:30 minutes late instead of 30 mins.

  2. Sach says:

    (Stop time) - (Start time) = (IF =0, then add one minute to stop time);
    (08:00.50) - (08:00.10) = 0 (error)
    Thus, 08:01 -08:00.10 = 1 (acceptable)

    Query: how do you write the formulae reflecting this?

    Thank you

  3. says:

    I would like to calculate elapse time how do I write a formualae to reflect that for e.g. start time 8:30 a.m. end time 7:40 p.m

    • John says:

      in C9 type your start time
      In B9 type in your end time
      Copy and paste the top line in cell D9

  4. Terry says:

    I need to be able to get the time worked from the start time, to the end time, 22:00 hrs start and 06:00hrs end.

    • John says:

      Change the format in cells b2 and c2 to custom [h]:mm:ss
      In cell B2 type in your start time
      In cell C2 type in your end time
      Copy and paste the top code in Cell D2

  5. Tay says:

    I need to find the total in DAYS you get when you sum a column. My column is in hours.


    if I want to Calcutta the total working hours for an employee excluding break time. how I can do this? i.e. below
    DUTY IN 23:00
    BREAK OUT 0:30
    IN 1:00
    BREAK OUT 5:00
    IN 6:00
    LEFT 11:00
    act WORKING HRS-....

  7. Renjee Philip says:

    There are multiple overlapping time line items e.g
    Renjee: Cell B 01:23 Cell C 02:23
    Renjee: Cell B 01: 40 Cell C 02:40
    Basically i need to figure out the exact time logged in i.e 01:23 - 02:40.
    Is there a way to work it in excel.

  8. Saiful says:

    Please give me a formula for total calculate...

  9. Woody says:

    Need to perform a calculation on an employee schedule (utilizing the 24 hour clock) where start time is 19:00 (A11) and end time is 03:00 (A12) and get an answer that is not in negative hours ( =SUM(A12-A11) currently returns -16). When I use the hours 16:30 (B11) and 23:30 (B12) that do not span midnight (2400) then the calculations are correct ( =SUM(B12-B11) currently returns 7:30), which I can easily convert to 7.5 hours, any suggestions without having to program the dates into the start times?

    • Will says:

      Hi Woody,
      just add 24 hours if the time will be negative :
      expl : check if value A12 is less then A11; if so add 24 to the difference, else just use the difference.
      Think it will work for you.

  10. Josh says:

    I struggled, pls help me. I am using an updated version and this wouldn't work for me. Do you know why?

  11. Samantha says:

    1 hour to two hours and three minutes how much longer?

  12. Brenda says:

    Using the 12 hour format, I am struggling to calculate the duration of hours when the start time begins at PM and the out time ends at AM. For example, if I wanted to find the duration of hours from 12:30AM(A1) to 3PM(A2), I would use the formula =(A2-A1)*24, which is 14.5 hours. BUT this does not work if I were to calculate the duration from 3PM(A1) to 12:30AM(A2), which is 9.5 hours but formula =(A2-A1)*24 will give me -14.5. What formula would I use to find the difference of time from PM to AM?

  13. Aldas Baltutis says:

    i am looking for the elegant way to calculate night and day power consumption. the problem is that night tariff is calculated from 23:00 to 7:00, and counter indications are not taken daily.
    26 October, 13:06
    28 October, 11:26
    4 November, 17:46
    how to calculate the time (hours and minutes) that can be attributed to the night/day time?

  14. JIGNESH says:

    Nakul Neel Ajay Ghanshyam
    Date in Out in Out in Out in Out
    1-jun 11:00 16:00 10:00 19:00 10:00 19:00 10:00 15:30
    20:30 02:00 - - - - 19:20 02:00
    2-jun 10:00 16:00 10:00 16:00 14:30 02:30 10:00 16:00
    20:30 02:30 - - - - 20:30 02:30
    3-jun 10:00 16:00 10:00 19:00 15:00 02:00 10:00 14:30
    20:30 02:00 - - - - 19:40 02:00

    How to calculate night/day

  15. Mahabub Alam says:

    If I have start time and end time in one cell, how can i get the toal # of hours. For example: in one cell I have: 05:00 pm - 10:00 pm. How can i get the total # of hours which is 5 hours?
    Thank you so much!

    • Pablo says:

      Is the end time always on the same day as the start time?
      Total Hours = (End time - Start time) * 24
      For example -> C1 = (B1-A1)*24
      A1 = Start time
      B1 = End time
      C1 = Total Hours
      Make sure the number format for the total hours cell is general or number.

  16. Madhumita says:

    How do I add 26 hours to a time if it has to calculate it by office hours say 9 - 19.

  17. anand Singh says:

    how can calculate extra working hours and minute in amount
    As like-
    Report Time Out Time Total time Working Time/per Day Extra working Time Per hours *50 Rs Extra working Amount
    08:00 22:50 14:50 12:00 02:50 00:00 ??????

  18. AD says:

    Hello. I need assistance with writing a formula to calculate holiday hours for anytime worked before 5pm.
    for example:
    Time in is 11:46 am and Time out is 4:39
    Time in is 2:00 pm and Time out is 12:00 AM

  19. Kushan says:

    I need to make my work sheet for counting my flying hours. It's like that,

    350.45hrs - 150.25hrs = 200.20hrs

  20. Agnes says:

    Hi, I'd like to count elapsed time but in the situation when dates and hours are in separate cells.
    A1=Start B1=2019-01-12 C1=6:00
    A2=End B2=2019-15-12 C2=20:40
    I'd like the result to be divided into full days (24h) and the remaining time.

  21. Edrick Bridget says:

    The difference between Old time New time= +/-

  22. Darío says:

    Excellent information. Thanks a lot.

  23. Purushothaman says:

    i given one small example for this comment box
    K Column 8:30 to L Column 10:00 =IF(K3>L3,1+L3,L3)-K3
    M Column Result is 1:30
    But in the Same M Column I need time difference in Minute in the same Cell like 90 minute

    • Phil Lawrence says:

      Change your formula to =(IF(K3>L3,1+L3,L3)-K3)x1440 and you will get your answer in minutes.

      1440 being the number of minutes in a day.

  24. Cindy says:

    I have start time and total hours worked for the day. How can I get the end time?

    • Hello Cindy,

      To find out the exact end time, just use the formula below:

      =A1+TIME(B1, 0, 0)

      Where A1 is the start time and B1 is the total hours to work.

      • Hiba says:

        Hello Alexander, Im working on an overtime sheet. Where I need to calculate times between(16:00 to 21:59) & (22:00 to 07:59) in different columns

        • Hello!
          I’m sorry but your task is not entirely clear to me.
          For me to be able to help you better, please describe your task in more detail. Please let me know in more detail what you were trying to find, what formula you used and what problem or error occurred. Give an example of the source data and the expected result. It’ll help me understand it better and find a solution for you. Thank you.

  25. Beth says:

    I have a schedule with start times and finish times.
    I made separate column for how many hours each day.
    How do I add these times up to find how many hours per week?
    From there I will need to make a separate sheet to calculate hours over 80 per pay period.
    I thought it would be something like this:
    =TEXT(R5:X5, "h:mm") but it isn't working

    • Phil Lawrence says:

      Hi Beth
      you have made your result to be TEXT and you cannot calculate with text.
      Also when a result is more than 24 hours you have to be careful with formats otherwise Excel will not display what you are expecting. Use cell format "General" or "Number" but not time. If you use time everything goes back to zero after 23:59 like a clock.
      Apart from that, then calculate as normal =sum(R5:X5) or if you really want to =Sum(R5:X5,"[h]:mm") The bracket around the h tells excel to go beyond the 24 hour constraint it normally uses and you need that. Make sure R5 through to X5 are numbers not text as well and watch those formats, it can mess up your calculations big time.

  26. Rockystart says:

    Can any one help to find available cars in every 30 mins interval during 24 hrs schedule
    total fleet (cars) 180 , routes 28. Pax capacity 14. turn around duration 90 mins per trip.
    next day i need to generate report with actual transported and available buses to find shortage of cars in every 30 mins / 1 hrs.

  27. Amos says:

    I have a formula to calculate time in excel, which works good, but if I clock in at say 6:30 AM, (cell, C3) it shows a total time, even if the other cells are empty. Is there a way to not calculate time until more then one cell is populated? It is to clock in and out, AM and PM. The formula is,
    Can someone please help me with this, or is there a better way of doing it? Thanks!

    • Phil Lawrence says:

      Just add some more nests to your formula to check if D3 and F3 are empty.
      =If(D3="","") will check D3 and if it is blank will make the cell with the formula in it blank as well. Build this check into your existing formula and you will get what you are after.

  28. M K Menon says:

    Thank you.

  29. Amos says:

    Ok, Thanks for your response, however I was not able figure out where to put that, should I put it in the very beginning? I just couldn't get it to work.I have IN, OUT, IN, Out, and if I put in say 6:30 for the first in without any of the others populated, the total time says 17.25 Hours, and I would like it to say 0 until I enter a out time. Thanks a lot for helping!

    • Hello Amos!
      Please use the formula below:
      =IF(COUNTA(C3:F3)>1, ((IF(C3>D3, D3+1, D3)-C3)*24)+(IF(E3>F3, F3+1, F3)-E3)*24, "")

      • Amos Smucker says:

        Hi Alexander, Thanks so much for the formula that you posted, and it works great for when I enter the IN time in the morning, but when I enter the IN time after lunch it shows the 16.5 hours again. I suppose I just need to add something? I am lost when it comes to these long formulas. So I have IN, OUT, IN, OUT I enter the time to the closest 15 minutes, then the total column shows the hours. Please let me know if you have any thoughts to get the time to show only the hours in the forenoon if I enter the IN time in the afternoon. Thanks!

  30. Amber Fryer says:

    I am needing a formula that subtracts hours worked from 40. I am needing to know the left over hours. Basically I need it to subtract worked hours for the week let’s say 25.50 from 40 hours allowed for the week and give me the sum of that. So 40 - 25.5 =14.50

    • Hello Amber!
      If you enter working hours in the hh:mm:ss format, you can find the sum with the help of ordinary addition. Suppose you type the time in cells B2:B7 and get the sum in cell B8. However, when you sum several time intervals, the result can turn out to be over 24 hours. In this case, Excel resets the sum to zero and starts the operation anew. To show the correct sum of working hours, please apply a special format to B8: open the Format Cells dialog window, go to Number -> Time and choose "37:30:55" from the Type list. Then enter 40:00:00 which is your maximum working time in a separate cell, e.g. C1. After that, change the formula in cell B8 to see the left-over hours:

      =IF(C1 < SUM(B2:B7), "Over 40 hours on "&TEXT((SUM(B2:E7)-C1), "hh:mm"), C1-SUM(B2:B7))

  31. Steve says:

    How can I convert times to decimals in military time? I'm trying to write a sheet where I input time in and time out using 4 digit military time (6 AM as 0600, 2 PM as 1400), and receive total hours worked. For example, I have time in as 0800, Time out as 1630, and I'd like to get an answer of 8.5 for the number of hours worked. Not 8:30. No colons. Just decimals where half hours are displayed as .5.

    Thank you

  32. SRI SINDHU says:

    i have to calculate time in calculate time i 24 hr formate and i have to mention time without ("AM","PM") how t calculate with formula in excel
    for eg
    if i state today 07:00 and i completed next day at 10:00 hear 07:00 is 7am and 10:00 is next day 10am hear i done my work above 24 hr (24 hr and "+" 3 hr extra) this how i can calculate with formula.....

    thank you

  33. John paul says:

    I have Excel sheet where open Date is available in A column, And Time is available in B column, and closing date & time available in C & D Column. How can i find total time duration between open date & closing date. Thank you for your advise.
    John Paul.

    • Hi John,

      The formula below will return you the number of days between open & closing date:


      In order to calculate this duration in hours, please use the following formula instead:

      =TIME(,(C24+D24-A24-B24- INT(C24+D24-A24-B24)) *24*60,)

      Note! Don't forget to set the Time format for cell E1.

  34. Manoj Hayaran says:

    AfterDifference in time than roundup gives wrong results when start time and end time is equal ROUNDUP((C3-D3),0)

  35. Jackie Caraball says:

    can someone help me with this formula I try many time to calculate the hour time to make total duration time and still I am stuck ca some one help=(IF(E4>F4,1+F4,F4)-E4)*X1440 me on that. It's not calculating the duration on time i am try to calculated this formula but its not helping

  36. Jackie Caraballo says:

    do im doing something wrong :(

  37. Shaff says:

    how to figure out the diffrence between time in days if some of them have end date and some dont?

  38. Paula Seidlitz says:

    I am trying to figure out how many hours worked in a day using military time. I am also trying to find the difference of hours worked from 8.5 hours. I have to work 8.5 hours a day. Sometimes I work more and sometimes I work less. I would like the formula to highlight a negative difference so I can make sure I work 8.5 hours a day.
    Thanks in advance for your help.

  39. Star says:

    I do have two columns with date and time. I want to calculate the difference between them (so, that is pretty easy, only subtract). My issue: 1. End date sometimes is "Null" - in that case I tried to solve by adding if and setting the difference time to 999 or so. 2. I would like output to be in Days, Hours, Minutes, but days shown only if they are >0; and I want result still be a number (for the graph later). Original fields are in format yyy-mm-dd hh:ss. Is there a way to display this? I believe it is possible to do with IF by putting "" if month value is 0, but won't that put the result to text field format? Also, that is pretty lengthy formula, maybe there is a function or format that I am not aware of?

  40. roxy says:

    How do you calculate the difference of day and time between days into minutes in one cell?

    for example:
    I have a email that came in last night at 8:30pm and i answered to the email at 10:30am the next day. How many minutes is in between of my response time?

    Also if it was during the weekend days how would it calculate the time?

    • Hello Roxy!
      I recommend reading the first part of the above article, 'How to calculate time difference in Excel', to answer your question.
      To be able to show more than 24 hours in a cell, please use this time format: "37:30:55". You can find it in the list of Excel time formats.

      If Saturday and Sunday are traditionally considered to be days off, it is possible to exclude those 2 days from calculations with the help of this formula:

      =IF(WEEKDAY(A3) < WEEKDAY(A2),A3-A2-2,0)

  41. louise says:

    I have made a simple work schedule to show when each colleagues shift will be.
    I have a single cell displaying their start and end time (eg 10:00-14:00).
    the next column is for the number of hours in their shift.
    Is there a way I can get it to work out the number of hours in the shift automatically, or would I have to have a start and finish time in separate columns.
    I use the same sheet to print and put on the notice board so need it reader friendly.


    • Hello Louise!
      Of course, it’s better to record the start time and end time in two different columns. But in your case, you can use the following formula:

      =TIMEVALUE(MID(A10,FIND("-",A10,1)+1, LEN(A10)-FIND("-",A10,1))) - TIMEVALUE(LEFT(A10,FIND("-",A10,1)-1))

      Remember to apply the time format to the cell with this formula.
      I hope it’ll be helpful.

  42. Austin says:

    In A1 i have a start time as 21:30:00 and in A2 an end time of 08:55:00 and have the formula of =IF(A2<A1,A1-A2+24,A2-A1)in A3; however A3 calculates as 12:35. Cells A1 and A2 set to [h]:mm:ss. Cells in A3 set to h:mm. I need A3 to calculate the actual time between 21:30 the previous evening to 08:55 the next morning in h:mm as the time of travel is through the night.


    • Austin says:

      Note: A3 should calculate to 11:25 (11 hours and 25 minutes) elapsed time since commecing at 21:30:00, but calculates AS 12:35 (12 hours and 35 minutes).
      Thanks for your support.

    • Hello Austin!
      If I understand your task correctly, the following formula should work for you:

      =IF(A1 > A2,A2-A1+1,A2-A1)

      I hope this will help, otherwise please do not hesitate to contact me anytime.

  43. Chris says:

    I have issue where I am entering time as text as we want to enter 9:00am in it's simplest form as 900 but have set format to 00":"00 which works well until you do calcualtions and sum totals.
    I have a spreadsheet with 2 examples on it but not sure if I can send to you:-
    !) entering time as text
    2) entering time as time
    both have there issues. We need to enter start time, end time then set a default for 30 min break which can be over typed with longer break (or if less than 5 hours worked no break) and sum the days paid hours.
    Hope you are able to give me some guideance on this.
    thanks, Chris

    • hello Chris!
      I'm sorry, it is not very clear what result you want to get. If you enter the number 900 in a cell, then you can convert it to time in another cell. Regardless of the format, a number, not time, will remain in this cell. Could you please describe your task in more detail and send us a small sample workbook with the source data and expected result to Please shorten your tables to 10-20 rows/columns and include the link to your blog comment.

  44. Sheree L says:

    Hello! I need to calculate the time between 05-05-2020, 07:16:58 and 05-05-2020, 07:17:02. This is how it is populated on a report I download. I have tried =C11-B11 as a suggestion and also =TEXT(C11-B11,"d:h:mm:ss"), but I think the comma after date is causing issues.

    • Hello Sheree L!
      The formula below will do the trick for you:




      Remember to set the time format in this cell.
      I hope it’ll be helpful.

  45. Alireza says:

    Hi, I want to calculate the elapsed time students attended my class online. The report shows the time in a format like this:
    2020-05-12 15:41:08
    When I subtract the value of the two cells, I give #VALUE! error. I need the results in h:mm format. I appreciate it if you could help me with a solution.

    • Hello Alireza!
      Most likely, you have a non-printable character in front of the date. You cannot see him. This often happens when importing data from other programs into Excel.
      Try using the CLEAN function:

      = CLEAN(C2) -CLEAN(B2)

      I hope this will help, otherwise please do not hesitate to contact me anytime.

      • Alireza says:

        Dear Alex!
        Thanks for the quick reply. Unfortunately, it doesn't solve the problem. The same #VALUE! error exists.

  46. Dev says:

    I want to substract 8:00hrs in cell 1 from 4:00hrs in cell2 and also if cell 2 value is 9:00hrs so result should be zero.
    Please help with query.

  47. Adam says:

    I'm racking my brain trying to figure this one out. I'm running a compliance audit whereby I need to work out how much time is worked before 6 AM and how much time is worked after. In other words, if my candidate worked from 1 AM to 9 AM, I need to be able to return a result that tells me 5 hours were worked before 6 AM. Any help is warmly appreciated.

  48. Erin Monnin says:

    I am trying to figure out how to subtract time in excel. For example, I have to complete 250 hours of course work this summer. I am wanting to subtract the total hours I currently have from 250 hours, to come up with the number of hours I have remaining. I have 13:45 hours right now and can't seem to get the formula right to subtract that from 250 hours.
    Any help would be much appreciated!

  49. ainthu says:

    hello. suppose i want to calculate OT hrs where staff sign in time is 9:00am and signout time is 3:00 pm. total working hrs is 6. after deducting 4 hrs which is compulsary to work, how could i find the exact time when OT starts? what will be the formula.
    thank you for the help in advance

  50. Barry Chandler says:

    Trying to subtract one time from another ... including milliseconds and microseconds.
    Format is HH:MM:SS.mmm µµµ
    Example: 15:57:53.529 016 - 15:57:52.896 516 = 0.6325
    Any help would be most greatly 'preciated!

  51. Alex R says:

    Looking to calualte the duration between today's date and the date something was entered into my system

    i.e. created date 06/01/2019 -looking for length of time between whatever inputted date verus todays date, can some one help with the formula please?

  52. NeonP says:

    Hi Alexander,
    May i know what formula do i use if i want the leftover number of minutes (don't need hours) for the below scenario and what format should i set it to?

    END BREAK TIME: 13:30

    Thanks in advance :)

  53. Malcolm says:

    Hi Alex, I need to calculate the hours between two dates but excluding the holidays or weekends.Please help

  54. Arun A R says:

    I want a formula for vehichle down time. The vehicle duty time is 08:am to 07:59pm. Then the vehicle down for continuous 3 days( 4th may 2020 11:35 am to 7th may 2020 06:20 pm). Then how many hours and minutes down in per day calculation.

  55. Satvinder pal Singh Panesar says:

    Dear sir I am having 80 customer around the world from - india how I can know the time of that cotumer to whome I want to talk, I know if my cutomer is in Totanto a time is GMT -5.30 and Totanto time is -4 how I will calculate in excel. Sheet. And same with other customers.please explain

  56. Xabier says:

    Mr. Trifuntov,
    I'm creating an excel file to manage the shifts of a restaurant and I'm having trouble to manage sums. The working shifts in most cases are divided in two (morning - evening). The columns represent the days of the week. For each worker / day I have four cells (morning (entry/exit) - evening (entry/exit). The problem arises when I don't include information in all the cells (because it is a day off/ the restaurant is close or the worker makes a continuous shift. The result in this case gives me as a result 00:00. When I want to calculate the total working hours during the week (sum) computes the 00:00 as 24 hours. What I can do to resolve this issue?.

    Many thanks in advance for your time, availability and expertise.

    • Hello Xabier!
      To show time in a cell for more than 24 hours, set the time format to "37:30:55"
      For me to be able to help you better, please describe your task in more detail. Please specify what formula you used and what problem or error occurred. Give an example of the source data and the expected result.
      It’ll help me understand it better and find a solution for you. Thank you.

  57. Ana B says:

    Hi, I just want to simply be able to subtract times in order to get the number of hours worked. For example, in the first column is 10:00 AM (A1), in the second column is is 2:20 PM (B1). I tried doing =B1-A1 to get the total hours, but the resulting cell is showing me 4:20 AM. How do I convert this cell into an actual number of hours, and not formatted in that way?

    • Jennifer says:

      Go to the cell in question (the one that is showing you 4:20 AM) and then go to Number Format, scroll down to More Number Formats, (alternatively you can just right click, then click Format Cells), on the Number tab click TIME, under "Type" click 13:30. This will give you your answer in the format I think you want: 4:20 meaning 4 hours and 20 minutes worked.

  58. Jennifer says:

    I have a timesheet and I would like to have a calculation that subtracts the end time worked from the start time worked but have it subtract 30 minutes if it is over 6 hours elapsed and also subtract 30 additional minutes if it is over 8 hours elapsed. We have part time and full time staff. There are also some full time staff who work longer hours and get an hour for lunch instead of a half hour. I have tried to modify this:
    which subtracts the 30 minutes but does not account for the staff that stays longer and takes an hour lunch.
    I have this
    =TEXT(O28-N28, "h:mm")-("0:30")
    but it just assumes the calculation is over 8 hours and subtracts 30 minutes.
    I am stuck. Any help would be greatly appreciated.

    • Hello Jennifer!
      I’m sorry but your task is not entirely clear to me. For me to be able to help you better, please describe your task in more detail. What data do you want to use to change your formula? Give an example of the source data and the expected result.
      It’ll help me understand it better and find a solution for you. Thank you.

  59. Steve Lemons says:

    I have a list of dates and times and need to total the number of entries that have the same hours:minutes (within a date). I'm having trouble comparing as with different seconds the cells are different even if the view (HH:MM) is the same and comparing the difference doesn't work if one is 8:23:45 and the next is 8:24:12 is there a way to subtract the seconds so there is always comparable minutes? The list is in ascending order.

Post a comment

Unfortunately, due to the volume of comments received we cannot guarantee that we will be able to give you a timely response. When posting a question, please be very clear and concise. We thank you for understanding!
60+ professional tools for Excel
60+ professional tools for Excel
2019–2007 to do your daily work
Incredible product, even better tech support…AbleBits totally delivers!
Deborah Bryant
Anyone who works with Excel is sure to find their work made easier
Jackie Lee
The best spent money on software I've ever spent!
Patrick Raugh
Ablebits is a fantastic product - easy to use and so efficient.
Debra Celmer
Excel is at its best now
Annie C.
I don't know how to thank you enough for your Excel add-ins
Jennifer Morningstar
Anybody who experiences it, is bound to love it!
Kumar Nepa
AbleBits suite has really helped me when I was in a crunch!
Nelda Fink
I have enjoyed every bit of it and time am using it
Christian Onyekachi Nwosu
It's the best $100 we've ever spent!
Mike Cavanagh
I love the program, and I can't imagine using Excel without it!
Robert Madsen
One word… WOW!
Dave Brown
Love the products!
David Johnston
It is like having an expert at my shoulder helping me…
Linda Shakespeare
Your software really helps make my job easier
Jeannie C.
Thanks for a terrific product that is worth every single cent!
Dianne Young
I love your product
Brad Gibson
Sheila Blanchard