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

The tutorial explains different ways to calculate times in Excel and demonstrates several methods of adding times and calculating time difference. You will learn a few useful formulas to sum times and add hours, minutes or seconds to a given time. Continue reading

Comments page 4. Total comments: 1022

  1. Hi! I am needing to calculate an arrival time for a surgical unit. We use the Time of surgery (in 24hr time) + duration of surgery (in minutes) + 1hour for recovery. I'd like to program this calculation into a spreadsheet that we can use for patient flow. Ex. surgery time 0830, duration of 120 minutes + 60 minutes of recovery = arrival time of noon (1130). How can I write a formula to make these conversions properly?
    Thank you!
    Karin

    1. Hi!
      If I understand your task correctly, the following formula should work for you:

      =A1+(120+60)/1440

      A1 - surgery time

  2. I am working with a time sheet. I want a formula. Our working hours is 9:00 hrs. So, if a person works for 9:00hrs or more, I want to map it to 8:00 hrs and remaining in overtime cell. can you please help?

    1. If you want a formula, explain in detail what result you want. The information you provided is not enough to understand your case and give you any advice.

      1. The Formula I want is to map 9.00hrs or more to 8 hrs.

  3. I am trying to figure out a formula for our time sheets. We have the work hours, that isn't the issue. My problem is converting the work hours to clock hours. For example someone works 7:30 hours, that is how we get it I have to then convert it to 7.50 to figure payroll. Does that make since what I am asking. Example of what we do
    5/15/2023 1:15 PM 3:14 PM 1:59 1.98
    Date clock in clock out hours worked I convert this manually looking for a way to automatically do this
    Thank you

  4. Hello, I am trying to subtract overtime hours from regular hours that are on 2 different cells but I keep getting #VALUE error

    Example: In cell A2 I have [42]:15 for total worked hours and in cell B2 I have [40]:00 for regular work hours
    The difference would be =A2-B2 to get a total of [2]:15, meaning 2 hours and 15 mins of overtime but I keep getting #value error.

    note: I am not working with date or time formats I would say, since they are hours worked, not time of the day

    I would appreciate your response

  5. Hi Alexander Trifuntov/Ablebits Team.
    With the condition:
    The working hours are Monday to Saturday from 09:00 AM - 06:00 PM and Sunday from 02:00 PM - 08:00 PM.
    Holiday only on public holiday (e.g. May 1, December 25)
    Ticket received on April 30, 2023 at 05:30 PM
    Ticket responded on May 2, 2023 at 09:30 AM

    Could you please help me, what is the Excel formula to calculate the timestamp difference above (in hours) excluding public holidays?

    1. Hi! Your request goes beyond the advice we provide on this blog. This is a complex solution that cannot be found with a single formula.

      1. Hi Alexander, really appreciate the response.
        How about with more simple condition:

        The working hours from Monday to Sunday from 09:00 - 18:00
        Full holiday (no working) only on public holiday such as January 1, May 1, December 25
        A. Ticket received on Sunday, April 30, 2023 at 17:30 B. Ticket responded on Tuesday, May 2, 2023 at 09:30

        What is the Google sheets formula to calculate the working hours of timestamp difference between ticket received and ticket responded above (in minutes)?

        The expected answer is 60 minutes: I have 30 minutes left on Sunday but still not responded, skip on Monday because it is holiday, and used 30 minutes on Tuesday to reply it.

        Tried to use NETWORKDAYS.INTL but it does not work. Really appreciate with your help.

  6. Hi,
    Can any one help me find solution for below

    When I'm downloading attendance from biometric machine, I'm noticed that punch in punch out will showing in single cell, now I want to find a formula for generate total working hour and OT,
    The main problem is I need to check each cell for total 30 days in month for a single person,
    And we have more then 400 people working, I'm calculating manually total 30x400, may i know is their any alternate solution
    Ex: 6:00 17:37

    I'm get like this

    1. Unfortunately, this information is not enough to understand what you need. Please describe your problem in more detail. Include an example of the source data and the result you want to get.

      1. Sir, there is no option for uploading an example pic, can you please suggest me alternate way

  7. I'm trying to calculate running hours for a fleet of vehicles over a week, however, I am encountering a problem - All vehicles are on the same sheet, each recognized by a unique code (multiple pieces of data are recorded for the vehicles each day, based on which vehicles are used. Not all vehicles are run every day.) I'm trying to implement a formula that can be carried from one week to the next and doesn't need to be re-coded each week based on the location of the vehicles on the sheet.

    In a nutshell, I need a variant on the "CountIf" or 'SumIf" formulas so that the program can recognize the vehicle codes, and then calculate the difference between the smallest and greatest number of hours. Would this be possible?

    1. Hi! I don't have your data, so I can't recommend any formula. But here is a detailed instruction for the SUMIF function to calculate the amount of time for each vehicle. If this is not what you need, explain in more detail.

  8. Hi, my organisation requires we complete our time sheets using excel. The date is selected via a drop down menu where it then automatically populates the next field with the actual day. My big problem are the start and end times where the columns AM and PM columns are separated and once again are selected by a drop list where either AM or PM can be selected. We are paid from start to end time over that 24 hour day minus the number of hours we actually slept during that overnight shift, In the next column after sleep time, I want to input the required formula to provide the number of hours accumulated as awake, (start to End on the following day) minus the sleep time. How would this be done noting I can't change the existing spreadsheet layout and only add the additional column after sleep time with my own calculations. Thanks

    Date SHIFT Client Start End Shift Type Sleep Time
    12/04/2023 Wednesday ACA Bob 10.45 AM 9.00 AM Day Shift 11pm to 6am
    13/04/2023 Thursday ACA Bob 9.00 AM 9.00 AM Sleepover 11.45pm to 6am
    14/04/2023 Friday ACA Bob 9.00 AM 9.00 AM Sleepover 11pm to 6am

    1. Hi! You can calculate the number of hours like this:
      (11pm - 10.45 AM) + (9.00 AM - 6am)
      I can't give you the formula because I don't know what cells your data are written in.
      If this does not help, explain the problem in detail.

  9. Hello,

    so I am trying to make a timesheet for my employee. I have their start time and end time of work. when I try to calculate total time they worked using timevalue formula, it gives me result in time format.

    for example, I have start time on c2 which is 5:45am and end time on d2 which is 7:45am , so I am trying to calculate hrs he worked using formula, but end result is 2:00am.

    how can I just get a hrs in Number but not in a time format.

  10. Hi,

    I am working on a document for my work to calculate times. Basically i need to have each block typeable for later use to where the calculation is still there for future use. That's the first hurdle. The second i have kind of figured out is to calculate the hours for next to be picked up (i.e. 4 hours , 5 hrs and so on. Then if the time falls into certain hours time frame i need it to factor the added time plus some because we cannot deliver at those times. Thank you

  11. Hello alexander,
    I'm trying to calculate the duration for multiple tasks between differentes dates, like 04/04/2023 08:00:00 and 05/04/2023 10:00:00 in date format.
    But i need to inlude only the working days and hours, which are:
    Opening hours: 08:00 to 16:30
    With mutiple breaks: 10:00 to 10:15 / 11:30 to 13:00 / 15:00 to 15:15.
    The tasks varies wildy in lenght, it can range from 2 hours to 2-3 days.

    Do you know a formula for this calcul?
    Thank you

  12. I'm trying to sum a total of each individual who has worked for the entire week. I have a data that I have calculated the daily working hours but I am unable to get a total of the entire week.

  13. I'm trying to calculate the amount of time I worked down to the exact minute for the entire month, but when I try to sum it it just adds time to each other in a 24 hour format, starting me from 0 again after every 24 hours

  14. Good Information regarding Duaration Calculation in all possible ways
    Thanking You
    Tandeep
    St Joseph's School
    Vijapur, Gujarat, India

  15. Hello, I have huge time data in the format, 00:07:15:20. I want to perform sums, divide them by other number variables to find variable per time, but whenever I change the format it doesn't seem to work instead, it reverts back to a format like this "08/01/1900 08:15:15"

    How do I resolve this?

    1. Hi!
      Your task is not completely clear to me. Explain what your format means and what actions you want to perform. Give an example expected result.

  16. Is there a way to set up a formula to calculate the elapsed hours/minutes only during certain timeframes/days?

    I.e. We want to calculate elapsed time from order received to order sent out. But we only want the elapsed time to calculate from Monday - Friday 8am-4pm. So if an order comes in at 7pm on Monday night, we want the elapsed time to start calculating as of 8am on Tuesday and continuing to track business hours only until the order is sent out.

  17. HOW TO TOTAL NUMBER OF HOURS AND MINUTES

    1. Have you tried the ways described in this blog post? If they don’t work for you, then please describe your task in detail.

  18. Drives me nuts. I got time formatted in HH:mm:ss and I try to get the difference between two times in seconds. I always get the output mm:ss if I multiply it by 86400 I get zero.

    Another problem I've encountered is that =(B2-((-9,59)/(465)*125)) outputs a value error. I don't get any of this.

    1. Hello!
      Question 1: Try changing the cell format to General
      Question 2: Check the value in cell B2. Check the decimal separator. Probably correct 9.59 You don't need so many brackets. =B2-(-9.59/465*125)

  19. I am looking to scan a barcode in column A, that then produces the date and time it was scanned in column B. When I use the the formula =IF(A1="","",now()) in column B, and I scan a barcode into A1, the correct time comes up. now when the formula is copied down the column, B2 appears blank (as it should). Then when you scan a new barcode into A2 any amount of time later after the first time, the current time appears in B2 and B1 changes to the new current time.

    I need a formula to calculate the time of the scan in the adjacent cell, that doesn't change unless the adjacent cell changes.

    1. Hi
      I’m trying to create a roster that calculates hours worked and automatically subtracts non paid breaks
      For example if someone works 12pm-7pm it would be 7 hour in total but minus 1 hour for unpaid breaks so the excel sheet should show 6 hours instead of 7.
      I can get the formula to add the hours but not sure what formulas to use to minus unpaid breaks

      1. Hi! Subtract 1 hour from the time difference. For example, by using the TIME function:

        =End time - Start time - TIME(1,0,0)
        or
        =End time - Start time - 1/24

    2. Hi!
      You can use a VBA macro to replace the formula with the current time when you enter a value in another cell.

  20. Hello,

    I have a situation where I calculate the answering time, but I do not want to calculate the time outside of working hours.
    For example:

    Time of receiving e-mail: 02.02.2023. 15:50
    Time of receiving answer: 03.02.2023. 08:30
    I want the result to be: 40 minutes.

    How to do it?
    Thank you.

  21. working schedule /day- 8.00 am to 5.00 pm wherein 1.00 pm to 2.00 pm lunch back
    one project start work 26/1/2023 at 11.00 am.
    weekly holiday=27/1/2023
    weekly holiday=28/1/2023
    time required to complete project =43 hr.
    Finished date & time of the project=??
    need formula plz??

      1. hi,
        thanks
        Finished date & time =2/2/2023 at 11.00 am
        but manually calculation actual finished date & time should =2/2/2023 at 3.00 pm.

        start time=26/1/2023 at 11.00 am (wherein work schedule =8.00 am to 5.00 pm),

        need help for solution please.

  22. Status Date Time Hours
    Exit 27-Jan-23 4:58:14 AM
    Entry 27-Jan-23 3:25:33 PM
    Entry 27-Jan-23 3:25:49 PM

    how i can get hours above

  23. HI,
    I'm trying to get total hours worked but its coming up 12:00:00 AM
    I'm using the AutoSum option
    Thanks

  24. Hi, Found your tutorials very useful. Kindly help with the below task.

    I'm trying to prepare a weekday-wise task schedule, for item dispatching purposes.
    I require to view the time with WEEKDAY (ie: WED 15:30).
    Ex: If the dispatch day/time of delivery of one item, is WED 15:30, our preparation starts 36 hours prior, so at " Preparation Time" column should be displayed as " TUE 03:30", where I can analyze the hourly workload on each Day of Week.

    Thanks.

    1. Hello!
      To extract the time from a date, extract the fractional part of the number using the INT function.
      For example,

      =IF((A1-INT(A1))>TIME(15,30,0),A1-36/24,A1)

      I hope it’ll be helpful.

  25. Im trying to count timestamps i made with a macro essential enters now() if another cell is filled but i want to count the time stamps that fall into a range of 9am-12am 1pm-3pm and 3pm-5pm any idea how to format timestamps so i can use count ifs to determine if they are within those ranges?

    1. Hello!
      If your values contain time, count the number of values by two criteria using the COUNTIFS function:

      =COUNTIFS(A1:A15,">09:00",A1:A15,"<12:00")

      I hope my advice will help you solve your task.

  26. Anyone have an idea how I can compute for cycle time? But only taking into account a specific timeframe.

    Example:
    Timeframe is 9:00AM to 5:00PM
    But the device was assembled with times:
    8:00AM-12:00NN
    3:00AM-7:00AM
    2:00PM-7:00PM

    Is there a formula where I can compute for the cycle time but only for 9:00AM-5:00PM time?

  27. Hi, I need your help.

    How to get the Duration time if this is the format?
    DATE TIME DURATION LOGIN TIME LOGOUT TIME
    30-Aug 01:00 PM - 10:00 PM 9:00:00 8/30/2017 13:00 8/30/2017 22:00

    I really need an answer for this. Thank you so much ♥

    1. Hi!
      Have you tried the ways described in this blog post? If they don’t work for you, then please describe your task in detail, I’ll try to suggest a solution.

    2. DATE-----------T------IME-------------------------- DURATION---------------- LOGIN TIME ----------------------LOGOUT TIME
      30-Aug------01:00 PM - 10:00 PM------- --------9:00:00 --------------------8/30/2017 13:00--------------- 8/30/2017 22:00

      This one. I need the formula for this. Thanks!

  28. Hi Guys...how do you convert two times into hours and minutes..

    Example

    6:00 am --start time
    8:30 --- end time

    Answer is 2.50 where the 50 is the 30 minutes divided by 60 (30/60)

    Need the formulae to work on various time differences like this

      1. Thank you as this was extremely helpful

  29. I know the start time 7:41 AM, I know the time out for lunch, 11:38 AM, I know when the time clocked back in after lunch 12:16 PM.
    The person has to work 8 hours. I need to calculate the ending time based off the three known times and the total duration of 8 hours.
    What is the formula for calculating the ending time?

    1. =TIME(8,0,0)-((Lunch Start - Start Time) + (Lunch End - Lunch Start))

    2. Hi!
      If I got you right, the formula below will help you with your task:

      =8/24+A1+(A3-A2)

      A1 -start time A2 and A3 - lunch time

  30. I am trying to create a excel formula which will return a result of decimal hours, calcluated from start time, end time and reported down time, currently I am using cell format h:mm AM/PM for start and stop time, and then I manually subtract the minutes reported for down time and convert sum to decimal hours. for example -->

    Raw Data:
    Start time 5:00 AM
    End Time 1:32 PM,
    Minus 87 minutes down time (which also varies daily)
    Manually calculated its 6.08 in decimal hours

    I am looking for a formula and cell format suggestions to have excel do the calculations after start, end and break data have been added to cells.

  31. Hi, Is there a formula to get the time range and date or just even the time range? Example 7/1/2022 0:49:00. This will fall into the 12am to 1am range under Friday? I am trying to get how many entries came on a certain day for a certain time range. Friday 12am-1am we received 10 tickets.
    Monday Tuesday
    6 AM - 7 AM

  32. Hello,
    I am trying to calculate regular hours and OT hours based on the clock.
    8am - 4pm is regular time
    All other times are OT.
    person would input this start time to end time, in A1,B1 (6:00,1300)
    from 6-8 would return OT hours (2), shown in cell C1
    from 8-1300 would return regular hours (5), shown in cell D1

    1. Hello!
      Calculate regular time with the formula:

      =B1-A1-IF(A1>A2,0,IF(A1>A2,0,MAX(A2-A1,A1-A2)))-IF(B1A2,0,MAX(A2-A1,A1-A2))
      =IF(B1

      1. Hello Alexander,

        I would like to ask which value A2 cell is referring to in your formula.

        I need to calculate regular time (8am-5pm) between to dates.

        1. Calculate regular time with the formula:

          =B1-A1-IF(A1>A2,0,IF(A1>A2,0,MAX(A2-A1,A1-A2)))-IF(B1<B2,0,MAX(B2-B1,B1-B2))

          =IF(A1>A2,0,MAX(A2-A1,A1-A2))

          where A2 is 08:00. B2 is 16:00.

          1. I am unclear about your formula(s) above.
            I put the following in:
            A1 is 06:00
            B1 is 11:00
            A2 is 08:00
            B2 is 16:00
            C1 is =B1-A1-IF(A1>A2,0,IF(A1>A2,0,MAX(A2-A1,A1-A2)))-IF(B1A2,0,MAX(A2-A1,A1-A2))

            1. It appeared to cut off my last couple of lines. With the formula above for C1, it returned 0.125. I was expecting 3. What is =IF(A1>A2,0,MAX(A2-A1,A1-A2)) used for and where?

              1. Hi!
                Use these formulas:

                =B1-A1-IF(A1>A2,0,IF(A1>A2,0,MAX(A2-A1,A1-A2)))-IF(B1<B2,0,MAX(B2-B1,B1-B2))

                =IF(A1>A2,0,MAX(A2-A1,A1-A2))

  33. Hi All,

    I have a range of times and im trying to get the start and end time for productivity so i can work out hours used

    I have a lot of staff so just trying to save time for myself

    I have a VLOOKUP for the start time which is fine
    But I'm using for the end time =MAXIFS(N:N,J:J,"="&O2) because I'm trying to find the biggest time in the range but is just returning back 00:00:00

    Any help would be much appreciated

    1. Hi!
      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.

  34. Hi - I found your blog very helpful. However, I am stuck when trying to find the difference between two date/time stamps while excluding hours outside of 8:00AM to 5:00PM. I know how to calculate NETWORK days and I know how to calculate hours between date/time. I just don't know how to exclude non-working hours.

    For example, Cell AA3 is (Autogenerated from database) 10/25/2022 2:21PM and Cell AC3 is 10/26/2022 8:44AM the difference should be 3 hours and 23 minutes (Excluding non working hours). How do I find the difference in NETWORKDAYS and hours together? Or do network days and hours need to be split up into two separate columns? I will need to average out the columns once I figure out the date/time differences between cells.

    Thank you and appreciate the help!

    1. Here is where I am at so far...should work...but it doesn't for some reason.

      =(NETWORKDAYS(A2,C2) -1)*(upper-lower)+IF(NETWORKDAYS(C2,C2),MEDIAN(MOD(C2,1),upper,lower),upper)-MEDIAN(NETWORKDAYS(A2,A2)*MOD(A2,1),upper,lower)

  35. Hi! Can somebody help me with a formula? I need to compute the rectification time duration between two separate opening hours in a day. The first Opening Hour is from 6:00am to 10:00am, the second is from 7:00pm to 11:00pm. The time in between 10am and 7pm is not counted because it's not within the Opening hours.

    1st scenario: If the rectification time is from 7:00am to 8:00am, then the duration is 1 hour.

    2nd scenario: If the rectification time is from 7:00am to 3:00pm, then the duration is only 3 hours (10:00am to 3:00pm is not counted because it's not within the opening hours)

    3rd scenario: If the rectification time is from 7:00am to 8:00pm, then the duration is 4 hours because the rectification time crossed over the second opening hour (from 7pm to 8pm)

    Hope somebody here can help me. Thanks a lot!

    1. Hello!
      The start rectification time and end time are written in A2 and A3.
      Opening hours are written in A1:D1.
      Try this formula:

      =IF(B1>A2,B1-A2,0)- IF(A1>A2,A1-A2,0) +IF(A3>C1,A3-C1,0) -IF(A3>D1,A3-D1,0)

      1. Hi Alexander! Thanks a lot for your reply but I always get the answer "4" every time.

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

          =(A2<=B1)*((A3-A2)-IF(A1>A2,A1-A2,0)-IF(A3>B1,A3-B1,0)) + ((A3-A2)-IF(C1>A2,C1-A2,0)-IF(A3>D1,A3-D1,0))*(A3>=C1)

          1. Hi! Thank you, Alexander. Will try this out.

        2. This is my formula but is only applicable for Scenario 1 above,
          where A2 is start time and A3 end time and B1 is end of 1st opening hour or 10:00am

          =IF(A3>=B1,A3-A2,0)

          When I apply the above formula for scenario 2 and 3, it will include the number of hours not within the Opening Hours.

          I just couldn't get around my head on this.

          Thanks!

  36. Hi I have the date and time data where as i need to calculate the hours in logic way
    for example : ( 01-12-2022 19:42:00 - 02-12-2022 11:55:00 = -16:13 Hours ) but if i have recd the data on 01-12-2022 post 6:30 PM the time should calculate from next day 9:30 am, so ideally the total time consume from ( 02-12-2022 09:30:00 to 02-12-2022 11:55:00 ) = 2:25 .

    Pls provide formula

    1. Alexander sir pls support

      1. Can any one support me in this formula

      2. Hi!
        If I understand your task correctly, try the following formula:

        =B1 - IF(A1-INT(A1)>TIME(18,30,0), A1+TIME(15,0,0)-(A1-INT(A1)-TIME(18,30,0)), A1)

        1. No Sir it doesn't work,
          My task is to understand you { Rec Time - 01-12-2022 13:26:00 } - { Send time - 02-12-2022 19:58:00 } = 30:32 Hour whereas here it is calculating the entire hours
          But if i remove the non working hours i;e from > 18:30 then and next day working hours i;e < 09:30 AM. and the send time is { Send time - 02-12-2022 19:58:00 } so ideally total time taken for work is = 10:28 hours
          one more example :
          Recd Time : 01-12-2022 19:42:00 - Send Time : 02-12-2022 11:55:00 = 16:13 Hours Logically
          But
          Recd Time : 01-12-2022 19:42:00 - Send Time : 02-12-2022 11:55:00 = 2:25 Mins ( Ideally it should calculate only working Hours ) i have manually removed working hours and calculated here i need this in formula

          Sorry for long texture.

          1. Hi!
            The formula I sent to you was created based on the description you provided in your first request. However, as far as I can see from your second comment, your task is now different from the original one.

            =B1 - IF(A1-INT(A1)>TIME(18,30,0), A1+TIME(15,0,0)-(A1-INT(A1)-TIME(18,30,0)), A1+TIME(15,0,0))

  37. if work start on 5-3-15 10:30 PM proposed work completed after 76478hr 45 minutes and daily working hrs are 6hrs how to calculate work completed time and date

    1. Hello!
      To calculate working time in days, use the recommendations from the article above:

      =INT(A2/6)+MOD(A2,6)/24+A3/1440

      A2=76478
      A3=45
      Then add to the start time.

  38. Hi
    In my workplace I constantly need to add 50% to the allotted written time for exams.
    For example exam time is:
    08.00-12.00 and for the students I take care of they get 50% extra time which here would be 08.00-14.00

    Is there a formula that can take the original time add 50% and show the result in clock time. If i write 08.00-12.00 I want the next column to show the written times with the added 50%. It would save me a lot of time to not have to count in my head and manually write the time..
    Thanx =)

  39. Hi,

    Is there a way I can combine the formula of concatenate date in one cell and get the difference between the two dates?
    Sample:
    Cell A1 10/24/2022
    Cell B1 13:35
    Cell C1 10/25/2022
    Cell D1 02:05
    Cell E1 =CONCATENATE(TEXT($A1,"mm/dd/yyy")&" "&TEXT($B1,"hh:mm:ss"))
    Cell F1 =CONCATENATE(TEXT($C1,"mm/dd/yyy")&" "&TEXT($D1,"hh:mm:ss"))
    Cell G1 Result

    Thank you in advance

  40. Morning

    I have used the Formula TEXT and found the time difference between two times across 4 rows, =TEXT(G1-F1,"h:mm:ss") (n.b. F:F and G:G data includes dd:mmm:yyyy if this has any bearing), which works successfully. In the Time Difference column I've copied the TEXT formula down the relevant rows to determine each time difference. At the bottom of the Time Difference column, =SUM(H1:H4) returns 00:00:00. Is there any reason this does not function as expected?

    Cheers

    Dan

      1. Excellent, thanks. I'll have another play.

  41. I have used the Formula TEXT and found between 2 different times the hours and minutes. I have done this for a whole month. but now i want the total hours worked on that month. Which function should i use?

  42. Hello Alexander! I am looking for a formula to calculate the years, days, and months along with a subtotal of the length of service. I could not get the subtotal to match the total of each hire date and ending day of this employee. I figured I will need to add the day in with the years and months. I still wasn't getting an accurate subtotal. What am I doing wrong? And how would I do the formula? Thanks!

    ID Last Name First Name Date Hired End Date Length of service
    1234 DOE DARREN 11/19/1998 10/18/1999 0 years,10 months
    1234 DOE DARREN 04/05/2001 02/05/2004 2 years,10 months
    1234 DOE DARREN 07/18/2004 01/12/2005 0 years,5 months
    1234 DOE DARREN 02/18/2009 08/29/2011 2 years,6 months
    1234 DOE DARREN 01/21/2013 08/10/2019 6 years,6 months
    1234 DOE DARREN 04/21/2021 05/09/2021 0 years,0 months
    1234 DOE DARREN 02/07/2022 10/04/2022 0 years,7 months

    SUBTOTAL

    1. Hello!
      I don't really understand what subtotal you want to calculate. However, I assume that the "Length of service" column contains text, not numbers. You can't execute any mathematical operations on the text.
      To calculate length of service, you can use this guide: Calculate number of days between two dates in Excel.
      Please provide me with an example of the expected result, and I will try to help.

  43. Hi Sir.Good Day.Please help me with the right formula of late,undertime and Overtime.Im always getting the wrong formula.
    Start Time=07:00
    End Time=16:00

    For late.6min-35min=0.5 36min-1.06hr=1
    For undertime.6min-35min=0.5 36min-1.06hr=1
    For Overtime.(17:00-17:29=1),(17:30-17:59=1.5),(18:00-18:29=2)

    A B C D E
    1 IN OUT LATE UNDERTIME OVERTIME
    2 07:06 15:55 0.5 0.5
    3 07:00 18:20 2

    Thank You,

    1. Hello!
      To find the desired time interval, use the MATCH function with Match_type=1
      In columns A and B, write down the values
      07:00 0
      07:06 0.5
      07:36 1
      08:06 1
      08:07 0
      14:54 1
      15:25 0.5
      15:55 0
      17:00 1
      17:30 1.5
      18:00 2
      18:30 0
      Formulas for calculating of late, undertime and overtime:

      =INDEX(B1:B5,MATCH(D1,A1:A5,1)) late
      =INDEX(B6:B8,MATCH(E1,A6:A8,1)). undertime
      =IFERROR(INDEX(B9:B12,MATCH(E1,A9:A12,1)),0) overtime
      Hope this is what you need.

  44. If i want to do an if statement based on the # of hours, what am i missing.

    eg. 4hrs=$50, 4-8hrs=$100, >8hrs=$150
    cell a1=1:00am, b1=6:00am, c1=b1-a1, d1=IF(C1<4,50,IF(AND(C14),100,150))

    I've tried the above but c1 does not give me 5 as the answer unless i turn it to "hour" format, and d1 gives me answer of 150.
    Final answer should be 100 as it falls within 4-8hrs.

  45. Hi! I'm having trouble creating the formula for counting working time with consideration of working hours.

    Working hours: 8:00 - 17:00

    Example:
    A1 = 8/18/2022 16:50 ; B1 = 8/19/2022 8:20 ; C1 should return 30 minutes.
    A2 = 8/18/2022 9:30 ; B2 = 8/18/2022 12:00 ; C2 should return 2 hours and 30 minutes.
    A3 = 8/18/2022 17:30 ; B3 = 8/19/2022 7:54 ; C3 should return 0 hours and 0 minutes.

    Hoping to get some help here. Thanks!

  46. Hi, Good day! I've been reading all the comments here but I cannot find any related of my problem here. I want to sum my time in one go and it goes like this:

    7:03-11:19 and 1:00-7:00

    I came up with a formula like this:
    =Round(Sumproduct(11:19-7:03)+(7:00-1:00)*24,2

    But as expected, it doesn't result to 10.27 hrs

    What formula should I use for it? Thank you in advance.

    1. Hello!
      Your data is written as text. To extract time from text, use the MID function. To convert text to time use the TIMEVALUE function.

      =TIMEVALUE(LEFT(A2,SEARCH("-",A2)-1))

      =TIMEVALUE(MID(A2,SEARCH("-",A2)+1,10))

      Find the time difference as described in the article above.

  47. Dear mister Alexander Trifuntov,
    I am sorry I make a mistake. I think this day my body was in bed in my head on the moon.
    All work perfectly.

    Do not know for what I want 11:30 – 3:00 = 3:30 since the real answer finally is 15:30 like in your formula.
    Sorry for this mistake and thanks a lot and have a nice day!

  48. Thanks for your feedback. Really appreciate.

    All 24H format (Format Cell > Time > 13:30)
    Example #1
    O8: 3:00
    P7: 11:30

    Normally must show 3:30
    Trying what you say:
    =IF(O8>P7,P7-O8+1,P7-O8)
    Give 15:30, which is not ok because show result on 24 formats.

    Example #2
    O11: 4:00
    P10: 14:30

    Normally must show 10:00
    Trying:
    =O11+1-P10
    Give 10:00, which is ok

    Thanks by advance!

    1. Hi!
      The result of your example 1 I can't understand and repeat. Excel stores time in 24-hour format. Please read the above article carefully. 11:30 is 11:30, not 23:30. Write the time correctly.

  49. Hi,

    In the following, I want: End – Begin.
    Format of time is 24 hours (0:00 = 24:00)

    For example:
    Begin 11:30
    End: 3:00

    End - Begin = 3:00–11:30 = 15:30

    Begin End
    11:30 3:00
    11:30 4:00
    14:00 4:00
    13:30 5:00
    10:30 4:30
    14:00 5:30
    12:30 5:00
    15:00 6:00
    14:00 5:00
    16:00 7:00
    14:00 7:00
    14:00 9:00
    17:30 9:00
    17:30 9:00
    14:30 9:00
    16:00 10:00
    13:30 0:00
    13:30 0:00
    5:30 17:00
    2:30 22:00
    3:30 22:00
    5:00 22:30
    4:50 20:45
    6:40 21:40
    6:15 22:30
    6:20 0:30
    6:05 0:30
    6:25 0:00

    Thanks by advance.

  50. Hello,
    I have read your post and the comments but I can't find what I need. I am trying to figure out the hours between days in military time. If possible I am trying to gee the dates in separate cells. i.e. Start date, start time, end date, end time. Product would be total hours. (3/19/2012, 0645, 3/20/2012, 1400, total is 31.25 hours)
    Please help,
    Thank you,
    Carlos

    1. Hello!
      Use the TIME function to convert text to time. Find the date and time difference and multiply by 24 to get the hours.

      =(C1+TIME(LEFT(D1,2),RIGHT(D1,2),0)-A1-TIME(LEFT(B1,2),RIGHT(B1,2),0))*24

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