+ Reply to Thread
Results 1 to 8 of 8

Calculating difference between two 24 hour times and dates

  1. #1
    Registered User
    Join Date
    05-02-2016
    Location
    New Zealand
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    21

    Calculating difference between two 24 hour times and dates

    Hi all,

    I'm trying to find out the difference between 2 times and dates that are in the format: dd/mm/yyyy hh:mm:ss and both in a 24 hour format. What would the best way to go about this be? The sort of result I'm looking for would be like the below example:

    12/04/2017 14:52:29 MINUS 12/04/2017 14:51:21

    With the result being how many minutes, hours and days difference, such as: 0 Days, 0 hours, 1 minute and 8 seconds.

    Any advice is much appreciated

  2. #2
    Forum Contributor
    Join Date
    02-04-2014
    Location
    NSW, Australia
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Calculating difference between two 24 hour times and dates

    Write your equation as you have there:
    =sum(Time1-Time2)
    Just change the format of the answer to hh:mm:ss

    Home>Number>Custom

  3. #3
    Registered User
    Join Date
    05-02-2016
    Location
    New Zealand
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    21

    Re: Calculating difference between two 24 hour times and dates

    Quote Originally Posted by lcartwright View Post
    Write your equation as you have there:
    =sum(Time1-Time2)
    Just change the format of the answer to hh:mm:ss

    Home>Number>Custom
    This has helped a lot, thanks! The only issue is where there's a difference in the day as well. Let's say:

    13/04/2017 14:52:29 MINUS 12/04/2017 14:51:21.

    How would I allow for this?

    On that topic as well, let's say the 13th was a public holiday and I wanted to remove the 24 hours of that public holiday from the equation. Is there a way I can work in the "networkdays" formula somehow so that public holidays and standard weekends are filtered out?

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Calculating difference between two 24 hour times and dates

    use this custom
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,034

    Re: Calculating difference between two 24 hour times and dates

    Specifically, this will be the custom format string (More Number Formats ... | Custom):

    d" days," h" hours," m" minutes and" s" seconds."
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,034

    Re: Calculating difference between two 24 hour times and dates

    To filter out holidays:

    =NETWORKDAYS(A2,A1) or =NETWORKDAYS.INTL(A2,A1)

    If you need to specify holiday date, add the range (e.g. C1:C5):

    =NETWORKDAYS(A2,A1,C1:C5) or =NETWORKDAYS.INTL(A2,A1,C1:C5)

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Calculating difference between two 24 hour times and dates

    ps networkdays strips the time information
    so only returns days
    you need to capture the time difference separately

    assuming C2:c3 is your public holidays

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-02-2016
    Location
    New Zealand
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    21

    Re: Calculating difference between two 24 hour times and dates

    Thank you humdingaling and AliGW. Between your comments, and lcartwright's earlier comment, I've been able to get everything working perfectly (with public holidays getting counted as expected). 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: 2
    Last Post: 04-01-2016, 12:03 AM
  2. Difference between two dates based on date and hour
    By cmorten82 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-25-2015, 12:09 PM
  3. hour difference between two dates/times, exclude weekends and holidays
    By lamdl in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-23-2014, 09:11 PM
  4. need help asap...calculating difference between 2 times
    By flipmagoo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-05-2012, 10:09 AM
  5. [SOLVED] Multiple times value addition at difference rate per hour
    By Khaldon in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-04-2012, 06:55 PM
  6. Calculating the difference in 2 times
    By km1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-24-2006, 04:42 PM
  7. Calculating difference between two times
    By Jaycatt in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-08-2006, 03:05 PM

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