+ Reply to Thread
Results 1 to 9 of 9

How to calculate elapsed time between to days excluding weekends.

Hybrid View

  1. #1
    Registered User
    Join Date
    11-27-2007
    Posts
    9

    How to calculate elapsed time between to days excluding weekends.

    I would like a formula to calculate elapse time between two days and return the result in Days Hrs Mins

    Current I got this formula

    =D10-C10-((INT(D10)-INT(C10))-NETWORKDAYS(C10+1,D10))

    Where C is start time and D the end time

    example:

    C = 14/10/2009 21:24:04
    D = 09/11/2009 09:47:09

    The above dates return 17 days 12 hrs and 23 min which is correct.

    The problem is the above formula does not work with any date range over 30 days or any dates in the same day for example:
    C = 14/10/2009 21:24:04
    D = 14/10/2009 23:24:04
    The above would return an error.

    Can anybody provide me with a formula that actually works for all scenarios.

    Please test your solution before posting. Thanks in advance.


  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to calculate elapsed time between to days excluding weekends.

    If start & end times always fall on working days then:

    =NETWORKDAYS(C10,D10[,holidays])-1+MOD(D10,1)-MOD(C10,1)

    where [,holidays] is optional parameter

    (above formula c/o daddylonglegs)

  3. #3
    Registered User
    Join Date
    11-27-2007
    Posts
    9

    Re: How to calculate elapsed time between to days excluding weekends.

    Quote Originally Posted by DonkeyOte View Post
    If start & end times always fall on working days then:

    =NETWORKDAYS(C10,D10[,holidays])-1+MOD(D10,1)-MOD(C10,1)

    where [,holidays] is optional parameter

    (above formula c/o daddylonglegs)

    Does this solved both issues?

    Thanks

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How to calculate elapsed time between to days excluding weekends.

    Are you unable to test ?

  5. #5
    Registered User
    Join Date
    11-27-2007
    Posts
    9

    Cool Re: How to calculate elapsed time between to days excluding weekends.

    Quote Originally Posted by DonkeyOte View Post
    Are you unable to test ?
    Just tested it and it works of for date range in the same day.

    But not for range greater than 30 days for example
    08/07/2009 17:05 - 03/11/2009 09:29 is returning 23 days, 16 hrs and 23 mins

    I really need one formula that works for both scenarios.

    Thanks

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,679

    Re: How to calculate elapsed time between to days excluding weekends.

    The number format dd:hh:mm doesn't work for durations over 31:59:59 because the dd part is actually a day of the month so 31 is actually 31st January, go to 32 days and it reverts to 1 (1st Feb).

    You either have to use decimals, i.e. just format as a number with 2 decimal places so you'd get 83.68 for the above example (0.68 of a day representing 16:23)....or if you want to see 83:16:23 then try this formula

    =NETWORKDAYS(C10,D10)-1-(MOD(C10,1)>MOD(D10,1))&":"&TEXT(D10-C10,"hh:mm")

    Note: this gives a text result so it's not so easy to use in any further calculations you may require
    Last edited by daddylonglegs; 11-23-2009 at 09:08 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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