+ Reply to Thread
Results 1 to 15 of 15

Number of Hours & Minutes between two Dates & Times. 1 min. Difference

  1. #1
    Registered User
    Join Date
    08-09-2018
    Location
    M.E.
    MS-Off Ver
    2016
    Posts
    9

    Exclamation Number of Hours & Minutes between two Dates & Times. 1 min. Difference

    Hey!

    So, I figured out how to calculate the Duration/Number or Hours and Minutes between two dates & times using the following Formula:

    A1 = 6/27/2019 | A2 = 10:00
    B1 = 6/29/2019 | B2 = 6:30

    C1 = To get the Hours =INT(((A1+A2)-(B1+B2))*24) Which would Result to = 44 hours
    C2 = To get the Minutes =INT(((A1+A2)-(B1+B2))*1440)-(INT(((A1+A2)-(B1+B2))*24)*60) Which would Result to = 30 Minutes
    (First part is calculating the number of Minutes then it subtract Hours in order to get clean result)


    Problem is, It's Not accurate!


    Real Example:

    While the Above showed a correct 44 Hours and 30 Minutes, Following Date & Time shows incorrect result with the same formula:

    A1 = 6/25/2019 | A2 = 15:00
    B1 = 6/27/2019 | B2 = 7:00

    C1 = 39 Hours | C2 = 59 Minutes

    Where it should be 40 Hours.

    A1 = 6/23/2019 | A2 = 1:30
    B1 = 6/23/2019 | B2 = 2:30

    C1 = 0 Hours | C2 = 59 Minutes

    Where it should be 1 Hour.

    It's not consistent, sometimes it would give a correct result, others it would Minus a minute which creates a problem with long records.
    End goal is to Sum the Number of hours and Minutes.

    File Attached, Dates are in Column [D] - Times are in Column [E] - Hours Formula in [F] - Minutes in [G]

    Help is greatly appreciated.
    Or if there's any other accurate method, please do say it!
    Attached Files Attached Files
    Last edited by SirTypos; 09-30-2019 at 01:04 AM. Reason: Attached file

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Number of Hours & Minutes between two Dates & Times.

    To best describe or illustrate your problem you would be better off attaching a dummy workbook. The workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    08-09-2018
    Location
    M.E.
    MS-Off Ver
    2016
    Posts
    9

    Re: Number of Hours & Minutes between two Dates & Times.

    Quote Originally Posted by FDibbins View Post
    To best describe or illustrate your problem you would be better off attaching a dummy workbook.
    Workbook attached!

    Dates are in Column [D] - Times are in Column [E] - Hours Formula in [F] - Minutes in [G]

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: Number of Hours & Minutes between two Dates & Times.

    First observation before checking anything - get rid of all merged cells - they play havoc with calcs.

  5. #5
    Registered User
    Join Date
    08-09-2018
    Location
    M.E.
    MS-Off Ver
    2016
    Posts
    9

    Question Re: Number of Hours & Minutes between two Dates & Times.

    Quote Originally Posted by torachan View Post
    First observation before checking anything - get rid of all merged cells - they play havoc with calcs.
    Done that, still inaccuracy occurs.

    For some reason, I'm suspecting decimals.

    When I add 1 Minute to Time, Say 10:01, the Results wouldn't change in Minutes formula = 00:00
    But! when I change it to 10:02, Minutes formula would record 1 Minute = 00:01

    Again, inconsistent, Sometimes it'll give accurate results, others it won't.

    How to get it Accurate 100% is what's frustrating
    Last edited by SirTypos; 09-29-2019 at 03:09 AM.

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: Number of Hours & Minutes between two Dates & Times.

    Attached one approach extracted from my vault of previous replies.
    It uses two simple hidden helper columns ( 'C' & 'F' )
    torachan.
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Number of Hours & Minutes between two Dates & Times.

    Try this

    Hours: =TEXT(D4+E4-D3-E3,"[h]")

    Minutes: =MINUTE(D4+E4-D3-E3)

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,728

    Re: Number of Hours & Minutes between two Dates & Times.

    Or try this:

    =ROUNDDOWN((D4-D3+E4-E3)*24,0)

    and this:

    =(((D4-D3+E4-E3)*24)-ROUNDDOWN((D4-D3+E4-E3)*24,0))*60
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,728

    Re: Number of Hours & Minutes between two Dates & Times.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  10. #10
    Registered User
    Join Date
    08-09-2018
    Location
    M.E.
    MS-Off Ver
    2016
    Posts
    9

    Re: Number of Hours & Minutes between two Dates & Times.

    I'll Test them out and get back with the results asap.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,728

    Re: Number of Hours & Minutes between two Dates & Times.

    I've already tested my suggestions. If your sample data is properly representative, they will work.

  12. #12
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Number of Hours & Minutes between two Dates & Times.

    Don't split the hour and minutes in 2 columns.
    Keep them in 1 and use the next formula
    Please Login or Register  to view this content.
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  13. #13
    Registered User
    Join Date
    08-09-2018
    Location
    M.E.
    MS-Off Ver
    2016
    Posts
    9

    Smile Re: Number of Hours & Minutes between two Dates & Times.

    So, whoever stumbles upon this post:

    Most guides when searching on google will recommend using the formulas in my Original post,
    But won't state that there will be a Minute difference in certain log events.

    ---------------------------

    Phuocam Hours formula stores it as text which can be fixed by adding it within =NUMBERVALUE()
    and Minutes formula worked.

    AliGW Formulas work as well, although in some cases, Minutes formula can result into (E-) Numbers
    Happened when tried to calculate this Event:

    6/18/2019 | 20:30
    6/20/2019 | 18:30

    Probably I did something wrong, change the cell formatting to Number instead of General.
    Corrected by AliGW on below post.

    So I basically combined AliGW Hours Formula with Phuocam Minutes Formula. and they both work

    torachan & popipipo Methods both helps if you don't want to separate the Hours from the Minutes by changing the Cell format to [Time -> 37:30:55]
    Which could help in summary reports for ease of viewing.

    ---------------------------

    To sum the total difference of Hours & Minutes I used the Following Formulas:

    Total Hours : =(Hours)+(INT((Minutes)/60))
    Total Minutes : =(Minutes)-(INT((Minutes)/60)*60)

    What it'll do, if the Minutes are above 60, It'll convert them into Hours in the Total Hours Formula and Subtract them in Total Minutes Formula.


    ---------------------------

    So far it's solved! No more 1 Minute Difference.

    Thank you all for the help!

    I'll report back if any issue occurred.
    Last edited by SirTypos; 09-30-2019 at 01:08 AM.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,728

    Re: Number of Hours & Minutes between two Dates & Times.

    It works perfectly as long as you set the cells with the formula to number format (not general):

    Excel 2016 (Windows) 32 bit
    B
    C
    D
    E
    F
    2
    18/06/2019
    20:30
    46
    0
    3
    20/06/2019
    18:30
    Sheet: Sheet1

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  15. #15
    Registered User
    Join Date
    08-09-2018
    Location
    M.E.
    MS-Off Ver
    2016
    Posts
    9

    Re: Number of Hours & Minutes between two Dates & Times.

    Done and Marked, fixed the result post with the correction.

    Thanks!

+ 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. Replies: 5
    Last Post: 10-21-2017, 10:26 AM
  2. 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
  3. Calculate "hours:minutes" difference between two "dates:times:minutes"
    By Neyme in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-26-2016, 11:03 PM
  4. Excel 2007 : Convert number of minutes to hours and minutes
    By MikeFromIndy in forum Excel General
    Replies: 30
    Last Post: 06-05-2015, 08:10 AM
  5. Calculate hours and minutes between two dates/times
    By farrellao in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-17-2014, 07:02 AM
  6. Formula to Calculate the Number of Hours Between 2 Dates and Times
    By Squint in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-11-2014, 03:28 PM
  7. Replies: 7
    Last Post: 08-15-2007, 08:33 AM

Tags for this Thread

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