+ Reply to Thread
Results 1 to 7 of 7

Date/Time Calculation - cannot use networkday - I have a working formula except holidays

  1. #1
    Registered User
    Join Date
    05-16-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    3

    Date/Time Calculation - cannot use networkday - I have a working formula except holidays

    I am using this formula to get the answer I need when subtracting one date/time column from another except I have a range of holidays that I need to subtract from these columns as well. My answer is in hours. Everything works unless there is a holiday.

    =24*((INT(AC2)-WEEKDAY(INT(AC2),2)+WEEKDAY(INT(AA2),2)-INT(AA2))/7*5-MIN(5,WEEKDAY(INT(AA2),2))+MIN(5,WEEKDAY(INT(AC2),2))+IF(WEEKDAY(AA2,2)<6,1-MOD(AA2,1),0)+IF(WEEKDAY(AC2,2)<6,MOD(AC2,1)-1,0))

    I have a list of holidays in these cells $AO$2:$AO$21

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Date/Time Calculation - cannot use networkday - I have a working formula except holida

    try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    where
    AE1:AE10 is holidays
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Date/Time Calculation - cannot use networkday - I have a working formula except holida

    ...but that won't consider the times, Martin....

    Hello, gamer39

    Why can' t you use NETWORKDAYS?

    Can your start/end times be at weekends or on holidays? If not try this formula

    =24*(AC2-AA2-SUM(INT((WEEKDAY(AA2-{0,1})+INT(AC2)-INT(AA2))/7))-SUMPRODUCT((AO$2:AO$21>AA2)*(AO$2:AO$21<AC2)*(WEEKDAY(AO$2:AO$21,2)<6)))

    format result cell as number
    Audere est facere

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Date/Time Calculation - cannot use networkday - I have a working formula except holida

    ah times i wondered what all those int() were for!

  5. #5
    Registered User
    Join Date
    05-16-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Date/Time Calculation - cannot use networkday - I have a working formula except holida

    yes I could not get the first formula to work. Kept getting reference error. This is a 24 hour cycle so Networkdays really messes me up (at least with my limited bit of working with formulas and functions). daddylonglegs I will try this. The start and end times can be anytime but there is a service level that we provide and we don't count weekends and holiday time against the service level. thanks!

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

    Re: Date/Time Calculation - cannot use networkday - I have a working formula except holida

    OK, from what you say you don't have a problem using NETWORKDAYS as long as it gets the right results? if start/end times can be any time then my earlier suggestion won't always work, try this version

    =24*(NETWORKDAYS(AA2,AC2,AO$2:AO$21)+NETWORKDAYS(AC2,AC2,AO$2:AO$21)*(MOD(AC2,1)-1)-NETWORKDAYS(AA2,AA2,AO$2:AO$21)*MOD(AA2,1))

    format result cell as number

  7. #7
    Registered User
    Join Date
    05-16-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Date/Time Calculation - cannot use networkday - I have a working formula except holida

    Thanks Daddylonglegs! I have spent hours trying to make something work! Your formula worked perfectly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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