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.

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:

=$B2-$A2

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

Notes:

  • 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:

=(B2-A2)*1440 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:

    =HOUR(B2-A2)

  • Difference in minutes, ignoring hours and seconds:

    =MINUTE(B2-A2)

  • Difference in seconds, ignoring hours and minutes:

    =SECOND(B2-A2)

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 below returns the following results, provided you've applied an appropriate time format to column B, h:mm in this example:

=NOW()-A2 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:

=TIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW())) - A2 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 How to show time over 24 hours, 60 minutes, 60 seconds.

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:

=A2-(3/24)

=A2-TIME(3,0,0)

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 the one below and get the result in the default format such as hh:mm:ss.

=SUM(B2:B4) 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:

=SUM($B$2:$B$4) 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.

For more information, please see How to calculate and show over 24 hours, 60 minutes, 60 seconds.

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 evaluation version of our Ultimate Suite below.

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!

Available downloads

Excel Time Calculations - formula examples (.xlsx file)
Ultimate Suite - trial version (.exe file)

962 comments

  1. hello dears i need help in my formula to give and get time from above or bellow if current cell have less value from G Cell
    i am using the Formula in E"=IF(F14-G14>0, F14-G14, TEXT(ABS(F14-G14),"-h:mm"))" it's show me how many hours it has less from 8 hours
    but now i want if
    E2 is less then G2 then get the hours/Minutes from above E1 if E1 has +value

    i am sorry i am not able to explain good it's because i don't know english much
    ___________________________________________
    | A B C D E F G
    |1 Sat 05 9:25 20:25 3:00 11:00 8:00
    |2 Sun 06 9:25 16:00 -1:25 6:35 8:00
    |3 Mon 07 9:25 20:25 3:00 11:00 8:00
    |4 Tue 08 9:25 17:00 -0:25 7:35 8:00

    • Hello!
      I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail? What result do you want to get? Give an example of the expected result.
      Explain the phrase in detail "E2 is less then G2 then get the hours/Minutes from above E1 if E1 has +value".
      It’ll help me understand it better and find a solution for you.

  2. One Hour 1000/- 1.30 hours How Many Amount Formals

  3. Hello!
    I am using =INT(K2-J2) to calculate the dates elapsed on for cells showing mm/dd/yyyy hh:mm:ss. In the cell the time is shown in military time, once I click into the cell the bar at the top shows the time in AM/PM. I am saying this because I think I have a data/formatting issue I can't resolve. I am also using =TEXT(K3-J3-INT(K3-J3),"HH:MM:SS"). These work okay although ideally I would like to not have to use two different cells to show the difference in days and times and have them combined in one cell... but I am picking my battles.

    The main issue that I am having is that I can't sum or average (i am really just trying to average here) the hour time lapse using =TEXT(K2-J2-INT(K2-J2),"HH:MM:SS"). I either get a div/0 error message or a 0. I have changed the formatting in these cells to various times, date and customs formats and nothing works.

    Additionally, I have another column with h:mm:ss formatting with values only and no calculation and I am able to average the data no problem. I am at a loss because I have copied the data and pasted in another cell so that no calculations were present in that column but still nothing...Im at a loss. Any help would be appreciated.

    • Hello!
      Unfortunately, without seeing your data it is difficult to give you any advice. Please provide me with an example of the source data and the expected result. It’ll help me understand it better and find a solution for you.

  4. Hello,
    I'm trying to create automatic production schedule. Work hours are from 7:00 to 23:00. I have current date and time. Work that requires 19 hours to complete.
    Need a formula that would pull up current date/time, add 19 hours and show end date/time but in respect to work hours. So if current time is 15:00 it should report end time to be next day at 18:00

    Any help?
    Thanks!

    • Hello!
      If I got you right, the formula below will help you with your task:

      =IF((HOUR(A2)+B2)>23,A2+TIME(B2,0,0)+TIME(8,0,0),A2+TIME(B2,0,0))

      A2 - current date/time, B2=19
      I hope my advice will help you solve your task.

  5. I need to get hours worked from a start time and end time. Then from that I need a new cell to add them up over a week and get total hours worked that week. Then I’m a new cell I need total hours for the week and hour pay

  6. I need to add data with how long it takes for an agent to complete a workflow. For example, an agent may take 3 mins and 51 seconds for 1 workflow. When I use the time format in Excel, even when I create custom ones in Excel, I'm having a hard time with it showing as 3:51, where 3 is the mins and 51 is the # of seconds. It always ends up showing as hours and mins or the time of day with AM/PM. How can I just get it to just show as 3:51, 3 mins, and 51 seconds. I need to add a lot of data and calculate the averages.

  7. login- 17:30

    Log out time - 3:00

    how to find the difference between these 2 timings

  8. Hello, I need to calculate the working time from a start time to an ending time and the report I run gives me the info like this. Do you know a formula that will help me ? fOLL
    Start End
    151517 152053
    152053 163714
    163714 165332
    165332 171444
    171444 173023
    173023 175441
    175441 180136
    180136 185950
    185950 193039
    193039 193636
    193636 201025
    201025 205052
    205052 212317
    212317 214440
    214440 220058
    220058 220152
    220152 222429
    222429 234425

  9. Hi!

    I'm looking a formula to find the time difference between 2 dates, but i don't want to use Cell A1-B1.
    Is there a formula which I can input date and time, and substract both in a single cell?

    So the 2 dates are:
    Commenced - 08/09 0330hrs
    Completed - 11/09 1510hrs

    I should get 3D 11H 40M, but i don't want to utilize 3 different cells to get the answer.

    Appreciate your help!

  10. hello. help needed,,, if possible pleasei have a run out time but what i need is
    if time is 3:30 (fixed ) computer clock say 2:45 (live) when clock reaches 3:30
    and though out the day 5:30, 6:14 etc;
    i would like for rows to totally turn red (as in late) and if i tick a box at end of row i would like it to turn green.
    (a2- a10)

    any help please

      • if somebody has to report in for work at i.e. 05:15 and they do not report in I want the excel row to auto highlight (red) when they report in and I tick a box at end of row hightlight to turn green,

        A1 (fixed number 05:15) , H1 now() so when now() passes A1 fixed time colour change (hightlight) also need to work out formula for this and when i tick the I1 it changes colour

        hopefully you can help!

  11. =IF(B2<A2,B2+1,B2)-A2 I AM USING THIS FORMULA TO FIND TOTAL WORKING HOURS OF AN EMPLOYEE.
    IF ONE EMPLOYEE ABSENT MEANS I ENTER ZERO VALUES IN TIME IN AND TIME OUT CELL .BUT ITS NOT WORK.
    MY DOUBT IS IF ONE EMPLOYEE ABSENT MEANS HOW TO AND VALUE ENTER IN TIME IN AND TIE OUT CELL.

    • Hello!
      Sorry, I do not fully understand the task. If A2 and B2 are 0, the formula returns 0. Please describe your problem in more detail.
      Explain exactly what the problem is. Give an example when the error appears. It’ll help me understand the problem you faced better and help you.

  12. is it possible for the below formula to be working days not just days??

    =IF(INT(M5-I5)>0, INT(M5-I5) & " days, ","") & IF(HOUR(M5-I5)>0, HOUR(M5-I5) & " hours, ","") & IF(MINUTE(M5-I5)>0, MINUTE(M5-I5) & " minutes and ","")

    TIA
    Steph

    • Hello!
      I believe the following formula will help you solve your task:

      {=SUM(--(WEEKDAY(ROW(INDIRECT(INT($A$1)&":"&INT($B$1))),2) < 6))-2 + B1-A1-INT(B1-A1)+(MOD(B1,INT(B1)) > MOD(A1,INT(A1)))}

      This is an array formula and it needs to be entered via Ctrl + Shift + Enter, not just Enter.

      Use custom date format

      d "d." h "h."m" min."

      I hope I answered your question.

  13. Hello!

    I need a formula which counts the transaction from (Date, 00:00:01 to 23:59:59) 24 hours and the count after 23:59:59 should go to next date.

    • Hi,
      I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail? What result do you want to get? Give an example of the source data and the expected result.
      Thank you!

      • Hello Alexander,

        I am trying to figure out a formula, which will calculate the transaction counts for a day (example: total transaction count for 18-Nov-20 (00:00:01 to 23:59:59) will be 100nos). Also, the counts that are calculated after (18-Nov-20 (00:00:01 to 23:59:59)) should fall to next day (19-Nov-20).

        Is there any formula that you can suggest?

  14. Hello, I need a formula that will help me determine how many calls were happening at 3:00 PM on 11/16. I need to figure out if 11/16/2020 3:00 PM falls between two dates and times.

    For example in row 2 I have join time and leave tine columns with the following data:
    I2: 11/16/20 1:00 PM J2: 11/16/20 1:01 PM
    I3: 11/16/20 13:40 J3: 11/16/20 14:30

    I have about 200 rows with date and times to go through so I need to see if the 11/16/20 3:00 PM date and time falls in between the dates above as well as the other rows. I need an output for each row (whether its true or false).

    After I get this data I can use a count formula to see how many times I get yes which will determine how many calls were happening at 3:00 PM on 3/16.

    My data expands over 48 hours.

    • I should have mentioned the date AND time are both in one column, it is not separated. I need to keep the date and time together.

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

      =AND(M1 > I1,M1 < J1)

      After that you can copy this formula down along the column. I hope my advice will help you solve your task.

      • Thank you for the information. Do I need to format the dates and time a certain way or format them as something? It's just returning no for everything when I most definitely have some Yes ones.

  15. How do i subtract from (29 minute:17 second:13 millisecond - 28 minute:15 second :90 millisecond) in excel

  16. Good afternoon, I have some days where I clock in at 5:00 am out at 11:00 back in 30 minutes later and then out at 1:30pm. But then there are some days in which I will be in and out 3-4 days in a day. example would be Monday 5:00 - 11:00, back in at 11:30 and work till 1:30. But today because I have to go into the office it would be 5:00 - 8:30, 9:15 - 10:30, 12:00 - 2:00, 4:00 - 6:00 pm. I have tried using: =IF(OR(B2="",I2=""),"",(C2-B2)+(E2-D2)+(G2-F2)+(I2-H2)) but the time will not round and I'm still coming up short. Whatever suggestion you have it would be TRULY APPRECIATED because I hate to have to make up time when I'm short 1 day and over the next.
    Sincerely,
    Frustrated!!!

    • 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 specify what you were trying to find 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.

    • Hi Alexander, I need a formula that tracks multiple times that I would clock in and out of work. Clock in the morning, then clock out for break, back in from break, then out for lunch, clock back in from lunch, then out for break, then return from break, then out for a second afternoon break then clock back in from that break until I clock out for the day.

      example:
      clock in at 5:00 AM, out at 7:00 for 30 minutes then i clock back in at 7:30, work from 7:30 until 11:00 then it's lunch from 11:00 am until 11:30 then i clock back in, then at 1:00 PM I clock out for 30 minutes and return at 1:30 until the end of my shift.

      so any formula you could share would be greatly appreciated.

      • Hello!
        I don't know how the data is written in your table. If each arrival at work and breaks in work are written in one line, then the formula may be as follows:

        =C2-B2+E2-D2+G2-F2+I2-H2+K2-J2+M2-L2+O2-N2+Q2-P2

        If there is anything else I can help you with, please let me know.

        • Alexander the formula works great. One last tweek if you don't mind. Our systems rounds up when keyed. I do truly appreciate your assistance, maybe i can stay out of trouble now. :)

            • the formula for time adds up across the cell and was wondering if there was a way to get the ending balance to round up? say i worked for 8 hours and 37 minutes, how to get this 37 minutes to round up to 45 minutes?

  17. 1st condition = should be after 8:30 AM
    2nd condition = should be before 4 PM
    Cannot find the right date. Struggle with AM/PM thing (confuse)
    for eg.

    =if(and(10:20 AM>=8:30 AM,10:20 AM<=4:30 PM),"within","out")

    note: 10:20 here is random time.
    Could you help whats wrong with formula and how can I get the right condition?

    • Hello!
      If I understand your task correctly, you need to use TIME function to compare time

      =IF(AND(A10 >= TIME(8,30,0),A10 <= TIME(16,30,0)),"within","out")

      Hope this is what you need.

  18. hello, how to calculate times between 9AM-9PM and 9PM-9AM if I have '14-Jan-20 05:00' (F2) as a reported date and '15-Jan-20 13:00' (G2) as a resolved date? Thank you in advance :)

    • and the output that I expected is 16:00 (means 16 hours) for 9AM-9PM and also 16:00 for 9PM-9AM :)

      • Hello!
        I wrote this formula based on the description you provided in your original comment. My result is 12 hours. Explain your calculations. Does 9 PM-9AM mean 21:00 - 09:00? Are you subtracting time or date and time? It is impossible to understand from your question.

  19. John,
    Wouldn't that cause a circular reference?
    C9: 8:30
    B9: 19:30 (which baffles me to put the End time in B and Stat time in C...?)
    Then, in D9, we subtract those two AND subtract D9 itself from that?... ???

    • Hello!
      I didn't quite understand your problem. But it might be useful.
      If start time is greater than end time, then you need to add 1 day to their difference

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

      I hope this will help

  20. what's the added formula if 1 hour must be deducted if you accumulated 6 hrs of overtime everyday?

    • Hello!
      I’m sorry but your task is not entirely clear to me.
      Please describe your problem in more detail. Include an example of the source data and the result you want to get. It’ll help me understand your request better and find a solution for you.

  21. I am making a spreadsheet to fully calculate how much pay I'm getting the only variable I'm stuck on is that I get paid %15 extra/hour after 6pm on weekdays. Is there a formula that checks for a time after 6pm and can return a value?

    Thank you if anyone can help.

    • Hello!
      Without seeing your data it is difficult to give you any advice. If time is written in cell A1, then you can compare it using something like this formula:

      =IF(A1>TIME(18,0,0),B1,0)

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

  22. I need to figure out how can i get event time/run time of every account having multiple transactions, i need time duration between First till last transaction of every account, every account having multiple transactions count.

    • All data is in one sheet, first column having account number, then amount then date time then type

  23. Hi there!

    I'm trying to track improvement in running times (e.g. how much faster someone is running 5km).
    So I was wondering if it is possible to subtract one running time (35 minutes 10 seconds) from a better running time (25 minutes 30 seconds) to see how much faster someone is running (-9 minutes 45 seconds).

    • Hello!
      I hope you have studied the recommendations in the tutorial above. It contains answers to your question.
      Pay attention to the following paragraph of the article above: Formula 3. Count hours, minutes or seconds between two times.

  24. Hey I have a timesheet that I would like to calculate the specific hours given is counted as overtime 1 which is from 22:00 PM - 06:00 AM, time after 06:00 AM will be calculated as overtime 2. I wanna get the hours worked in oveRtime 1 is how many hours? is that possible.
    For example:
    TIME IN (A1) = 12:00AM
    TIME OUT (B1) = 11:00 AM
    hours worked in overtime 1 is 8 hours, and in overtime 2 is 5 hours.

  25. hey so i have a timesheet for work i need it to calculate total hours, overtime 1 and overtime 2
    where hours from 07:00-15:00 is normal hours so no overtime counted
    hours from 15:00-17:00 is counted in overtime 1
    and all other hours is counted in overtime 2
    like so
    if A1(start time)=07:00 B1(end time)=19:00 C1(total hours)=12 D1(overtime1)=2 E1(overtime2)=2
    or A1(start time)=04:00 B1(end time)=16:00 C1(total hours)=12 D1(overtime1)=1 E1(overtime2)=3

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

      =B1-A1

      =IF(AND(B1>TIME(15,0,0),B1<TIME(17,0,0)),B1-TIME(15,0,0),TIME(2,0,0))

      =IF(B1>TIME(17,0,0),B1-TIME(17,0,0),0)

      I hope it’ll be helpful.

  26. I need to calculate sub of two times Eg: 06:00-09:00 in 24HRS
    Ans should be in 24HRS Format
    I want to get 21:00
    Can you help Me?

  27. Hello.
    I'm looking for a formula. I made one that gives the total worked hours. But my problem is, let's say the office time starts at 8am, the formula includes the time over or under 8am which the minutes for late and early in is computed.

    • Hello!
      If start time is greater than end time, then you need to add 1 day to their difference

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

      I hope this will help

      • Thank you for help works well

  28. I want to deduct time with a frame of more than 15 mins. For eg

    13.00pm
    13.01pm
    13.45pm

    Now it should skip the middle and select the next one. This type of format can be with more than 3 numbers

    • Hello!
      I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail? What result do you want to get?

  29. Hy. The formula works. I have the same schedule format. But how do I sum up with this formula for multiple days to get the final time number?

  30. I have 12:10 formatted as [hh]:mm in cell A1. How can I separate the hours and minutes so that the hours appear in A2 and the minutes appear in A3?

  31. How to get diff in days,hours,minutes,seconds,milli seconds for below
    Min time stamp: 2019-06-14 09:16:13.013
    Max time stamp: 2019-09-14 09:16:12.310

    • Hello!
      Find the difference between these dates using normal subtraction. To determine the difference in time in days, hours, minutes and seconds, apply the formula to the cell with the result:

      =INT(A1)&" days "&INT(MOD(A1,INT(A1))*24)&" hours and "&MINUTE(A1)&" minutes, "&SECOND(A1)&" seconds"

      I hope my advice will help you solve your task.

      • I need for milliseconds as well. Above works until seconds only.

        • Hi Alexander Trifuntov (Ablebits.com Team),

          =INT(A1)&" days "&INT(MOD(A1,INT(A1))*24)&" hours and "&MINUTE(A1)&" minutes, "&SECOND(A1)&" seconds"

          Can you also add calculation for milliseconds as well in above?

  32. Need Excel formula for calculating the hours and minutes between to different AM and PM high tides. The two different AM (A1) and PM (B1) times could be different. The A2 could be a higher number then the B1 time number and vise versa. Need this formula for calculating this for each day of the year.

    • Hello Robert!
      If the end time is longer than the start time, then you need to add 1 day to their difference

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

      I hope this will help

  33. I am trying to create a spreadsheet to calculate labor pool hours in a spreadsheet when the employee is unable to clock in onsite and they are reporting IN and OUT punches. However, we use Kronos which rounds to quarter hours (example: if an employee clocks in at 8:07 am, it rounds back to 8:00 am but if they clock in at 8:08 am, it rounds forwards to 8:15 am.) If I were trying to add their IN and OUT punches to a spreadsheet and have a total time worked, is there a way to have it automatically take in to account the Quarter Rounding aspect of Kronos time to give them an accurate total time worked?

    • Hello Amber!
      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. 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.

  34. I need help writting a formula that sums minutes between two specific times, for example start 9:10am - end 9:45am. I need to sum how many minutes were between 9:00am and 9:30am (20 min) and how many between 9:30 and 10:00am (15 min).

  35. I'm comparing timing for similar operations for recoding variables between R, SAS, Python and Excel. I need to calculate how long it takes, in seconds, to 3 decimal places (s.###), for a formula to calculate on an entire column in order to test the timing difference between two different formulas in Excel. Is there a way to do this? I would like to have a unique start/end time per column for when the refresh actually got to that specific column.
    e.g. for each column something like this? (untested):
    c1[=now()] d1[=now()] .... f1[=(d1-c1)*86400]
    c2[=a2*b2] ..... .... f2[=(e1-d1)*86400]
    c3[=a3*b3]
    .... ......
    Thank you for your time & reply!

  36. Hello!
    This may be simple, but I have been struggling with it. I have a report that puts out the time someone is on a call as 1:01:24 AM, when it is actually a period of time equaling 1 hour, 1 min, 24 seconds. No matter what format I put on the cell, I cannot seem to get it to change it over to the actual time period instead of the clock time of 1:01:24 AM. I am trying to do this as I would like to be able to take a list and add all of the times for the day. Can anyone help with this?

    • Hello!
      I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail?
      Write an example of the source data and the result you want to get.
      It’ll help me understand it better and find a solution for you.

  37. Hi, my roster is published with start & finish in the same cell. is there a way to tell the time difference between start & finish (I need an 11 hour break)?

    • that should read betrween finish & start - between days

    • Hello!
      Please describe your problem in more detail.Include an example of the source data and the result you want to get. It’ll help me understand your request better and find a solution for you. Thank you.

  38. Hello,

    If we are Summing times in a "total" cell, how do you include days? So far I managed the following:
    =SUM($D$2:$D$4)&" days, "
    this got me 39.7148.... days
    but it does not breakout down into days, hours, minutes, and seconds like the interval equation or the subtraction formatting did.
    If I manipulate the format and just sum the range, instead I get like 929 hours, 9 minutes, and 21 seconds instead of it breaking it down into days.
    What I want is for the total cell to show the total times added together as something like "38 days, 17 hours, 9 minutes, 21 seconds"

    • Hello Samantha!
      To display the total amount of time in days, hours, and minutes, use the formula

      =INT(A1)&" days "&INT(MOD(A1,INT(A1))*24)&" hours and "&MINUTE(A1)&" minutes, "&SECOND(A1)&" seconds"

      I hope it’ll be helpful.

  39. Hello
    I want to calculate time elapsed between 2 dates and times h:m
    then i want the result in minutes rounded up to the hour if more than 50 min

    • Hello!
      The following formula rounds the time to an hour if the number of minutes is more than 50:

      =IF(MINUTE(A1)>50,ROUND(A1*24/1,0)*(1/24),A1)

      I hope my advice will help you solve your task.

  40. Hi how do I calculate the difference in time of my end time is going to be in a different cell each time my start time will always be in B2 for example but my end time moves depending on the amount of tasks performed.

  41. 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.

    • Hello Steve!
      If your data is written in column F, then you can use the formula to count duplicate hours and minutes

      =SUMPRODUCT(--(HOUR($F$2:$F$6)=HOUR($F$2)), --(MINUTE($F$2:$F$6)=MINUTE($F$2)))

      and then copy it down along the column.
      You can read about finding duplicates here.

  42. 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:
    =IF(ISERR(O28-N28),N28,MOD(O28-N28,1)-(MOD(O28-N28,1)*24>6)/48)
    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.

  43. 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?

    • 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.

  44. 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.

  45. 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

  46. 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.

    • Hello!
      If the first date is written in cell A1, and the second in cell A2, then the formula
      =(A2-A1)/number_of_days
      Set the time format to "37:30:55" in the cell with the formula

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

  48. 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?

    START BREAK TIME: 13:15 (IN 24HOURS)
    END BREAK TIME: 13:30
    TOTAL TAKEN: 0:15 (MINUTES)
    LEFTOVER NUMBER OF MINUTES (IF I'M GIVEN 30MIN OF BREAK TIME): ?

    Thanks in advance :)

    • in another words, i have recorded the break time used which is 0:15 minutes after subtracting a time from another time. i need a formula to show how much time is left if break time is given for 30 min.

      thanks again!

    • Hello!
      To subtract time in Excel, use the usual subtraction formula =A2-A1
      You can use other methods of calculating the time difference, which are indicated in the instructions above.
      Please go to Format Cells, choose Number -> Custom Format and set
      mm:ss
      In this case, the number of minutes will not exceed 60

  49. 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?

  50. 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!

    • If the time difference is negative, add 1 day (24 hours)

      =IF(B3 > B1,B1-B3+1,B1-B3)

      To the start time you need to add 1 day.
      I hope it’ll be helpful.

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)