+ Reply to Thread
Results 1 to 18 of 18

Calculate number of hours and minutes between 2 date and time

  1. #1
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Calculate number of hours and minutes between 2 date and time

    Hi,

    I have a query start date & time as 26-09-2019 13:28 & query solved date and time as 27-09-2019 13:48 in cells A4 & B4. I work in a shift that starts at 12:30 PM( named as lower) PM to 9:30 PM(named as upper). To find the duration between these start and end time within my shift timing I use this formula and that works perfectly and gives me a result of 9:20 as duration

    =IF(B4="","",(NETWORKDAYS(A4,B4)-1)*(Upper-Lower)
    +IF(NETWORKDAYS(B4,B4),MEDIAN(MOD(B4,1),Upper,Lower),Upper)
    -MEDIAN(NETWORKDAYS(A4,A4)*MOD(A4,1),Upper,Lower))

    link:https://exceljet.net/formula/get-wor...ates-and-times


    But, if start date or end date falls on a week end then this gives me 0:00:00 due to networkdays formula

    eg
    29-09-2019 13:28 & query solved date and time as 30-09-2019 13:48 the result of the formula is 0, can someone please help me with formula that gives the duration for week ends as well.

    thanks for the help in advance
    Regards
    Arvind

  2. #2
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Calculate number of hours and minutes between 2 date and time

    Beware!! My english is not so well , so I may mis-understand your request. >_<

    Please try to change/remove this part and check the result.

    =IF(B4="","",(NETWORKDAYS(A4,B4)-1)*(Upper-Lower)
    +IF(NETWORKDAYS(B4,B4),MEDIAN(MOD(B4,1),Upper,Lower),Upper)
    -MEDIAN(NETWORKDAYS(A4,A4)*MOD(A4,1),Upper,Lower))

    will be
    =IF(B4="","",(B4-A4-1)*(Upper-Lower)
    +MEDIAN(MOD(B4,1),Upper,Lower)
    -MEDIAN(MOD(A4,1),Upper,Lower))

    I may understand more clear if you can upload a sample file with wanted result.

    Regards.

  3. #3
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Calculate number of hours and minutes between 2 date and time

    Hi,

    Thanks for the response, the formula is not working as per my requirement.

    below is the screen shot

    .Capture.PNG

    what i am looking for is, I work only in the shift of 12:30 PM to 21:30 PM, any tickets that are raised I am supposed to solve only during my shift. in 3rd record, though the request was raised at 8:15 am in the morning
    I assume its raised at 12:30 PM and then i solved at 15:05 which gives 2hours 35 minutes, however the result is wrong for 1st record, 2nd record etc.

    Thanks for your help

    Regards
    Arvind

  4. #4
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,483

    Re: Calculate number of hours and minutes between 2 date and time

    Please Post the example file and not a screenshot.. that will make it a lot easier for us to help you.

    Instructions on how to post are in the Yellow banner at the top of your screen

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: Calculate number of hours and minutes between 2 date and time

    After 180+ posts you should know that attaching a sheet makes life easier and gets you faster answers .

  6. #6
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Calculate number of hours and minutes between 2 date and time

    I've couple of question to ask before continue,

    You said that it's your shift time , that's mean there are others shift time right ?
    And how to handle (or count) shift that cross weekend or holidays over mid-night?
    (Continue to count until end to next SAT?/SUN?/Holiday? , or , stop at 00:00 )
    [It's may need to prepare on the first hand, in case your time shift changed or
    want to implement to use with others. ]

    On each request only shift owner will be solved , others can not (or will not) solved it ?

    Regards.

  7. #7
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Calculate number of hours and minutes between 2 date and time

    In this file there are some agreement to complied.

    1. Only one report sheet.
    2. Multiple shift sheet is possible.
    3. Stop date/time MUST greater than start date/time.
    4. Amount of rows in shift sheet must greater than
    (first date - last date) * 24 rows + 10 .
    (ie. if calculate = 100 , it should be 110 rows)
    5. Helper columns is needed.

    Concept (or calculation process).

    1. Prepare helper sheet for calculate count/not count time.
    2. Seek for proper start / stop time.
    3. Adjust gap between proper start and start , proper stop and stop.

    And since web site not allow me to post formulas (It say something about web html etc.)
    So, please review in the file.

    Regards.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Calculate number of hours and minutes between 2 date and time

    My bad,

    please accept my sincere apologies. I should have that done that. just slipped out of my mind.

    Regards
    Arvind

  9. #9
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Calculate number of hours and minutes between 2 date and time

    Thanks Menem, need a little modification for minutes.

    just to simplify, can we just look at Number of hours and minutes between Issue raised vs resolved irrespective of weekends, shifts or holidays?

    Regards
    Arvind

  10. #10
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Calculate number of hours and minutes between 2 date and time

    In case you want to count for all days.
    Please try this formula.

    C2
    Please Login or Register  to view this content.
    A2 = Start (Request) date/time
    B2 = Stop (Solved) date/time
    G1 : Start Shift = 21:30
    G2 : Stop Shift = 12:30
    G3 : Time Gap =
    Please Login or Register  to view this content.
    Note : It's look like a SLA count ?

    Regards.
    Attached Files Attached Files
    Last edited by menem; 11-27-2019 at 04:51 AM. Reason: Add note

  11. #11
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Calculate number of hours and minutes between 2 date and time

    Hi,

    This worked.. thank you so much for the help

  12. #12
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Calculate number of hours and minutes between 2 date and time

    Hi,
    sorry for re-opening this, for the actual data its not working. Attached the sample file. When request time and solved date are in same day, then it works, if different dates its not working.
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Calculate number of hours and minutes between 2 date and time

    You need to give your expected answers, rather than say it is not working. It is not helpful for people wishing to assist you

  14. #14
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Calculate number of hours and minutes between 2 date and time

    HI,

    added a sample file again with desired result for 3 rows.

    bascially what i am looking for:

    I work in a support team, users/customers can raise ticket any time, but i will solve only during my shift timings which 12:30 to 21:30 & i wanted to know how much of time that i taken to solve the issue.

    if someone raise ticket at 10:30 and i solved at 13:30, this duration might show 3 hours, but actually i solved within 1 hour from during my shift,
    similarly if i solve the next day, then 9 hours of day 1 + 1 hour of next day which will be 10 hours that i have taken to solve this.

    hope i explained my requirement clearly this time

    Regards
    Arvind
    Attached Files Attached Files

  15. #15
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,572

    Re: Calculate number of hours and minutes between 2 date and time

    This proposal employs three helper columns (I:K) which may be moved and/or hidden for aesthetic purposes.
    Column I covers tickets resolved in one day using: =IF(MOD(B3,1)<C3,"",IF(INT(A3)=INT(B3),MIN(D3,MOD(B3,1))-MAX(C3,MOD(A3,1)),""))
    Column J covers tickets resolved in two days and partially covers tickets resolved over more than two days, using: =IF(INT(B3)>INT(A3),SUM(MAX(0,D3-MAX(C3,MOD(A3,1))),MAX(0,MIN(D3,MOD(B3,1))-C3)),"")
    Column K covers the remainder of tickets that take more than two days to resolve using: =IF(NETWORKDAYS(A3,B3)>2,(NETWORKDAYS(A3,B3)-2)*TIME(9,0,0),"")
    Column G may then be populated using: =SUM(I3:K3)
    Note that the formula for column G is shown in column L in the attached file and agrees with 2 of the 3 desired results. I don't understand how G3 could be 9 and G4 be 9:15 instead of 10:15.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  16. #16
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Calculate number of hours and minutes between 2 date and time

    Please test in this file (I've back to my original file +option to count on weekend)
    But 2nd row , my file got 10:15 hours not 9:15 hours.

    And sorry for reply late.

    Regards.
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    03-28-2008
    Location
    India, bangalore
    MS-Off Ver
    Excel 2003,2007
    Posts
    216

    Re: Calculate number of hours and minutes between 2 date and time

    This worked thanks JeteMc and rest as well...

  18. #18
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,572

    Re: Calculate number of hours and minutes between 2 date and time

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Calculate the number of days, hours, minutes and second between two dates
    By Trelacmv in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-12-2017, 06:26 AM
  2. [SOLVED] Calculate number of hours from Start date and time and End date and time
    By sathyasun in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-28-2013, 01:04 AM
  3. Replies: 6
    Last Post: 12-01-2012, 05:28 PM
  4. Calculate minutes into hours in number format
    By ELTAMA in forum Excel General
    Replies: 3
    Last Post: 01-27-2012, 08:12 AM
  5. Replies: 1
    Last Post: 11-02-2011, 06:50 PM
  6. Replies: 1
    Last Post: 11-02-2011, 06:44 PM
  7. Replies: 2
    Last Post: 01-21-2010, 11:09 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1