+ Reply to Thread
Results 1 to 25 of 25

NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Greetings.

    I am developing a spreadsheet to track travel days for tax purposes. I have already used the networkdays function as well as an array function to give me a total of days for multiple personnel minus overlap days. What I am trying to do now is puzzling me.

    The following is a generic example:

    Start Date: End Date: Total:
    8/01/2013 8/15/2013 11
    9/15/2013 9/27/2013 10



    Now,

    What I need, is a function to put in column "C". If the start date or end date fall on a weekend, it must subtract 1 from the total. If both the start date and end date fall on a weekend, then obviously the total would be subtracted by 2.

    I have a feeling this is a simple IF THEN statement, but it is late. I appreciate all who can share their knowledge. Thank you.

  2. #2
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    =networkdays(start date, end date)

  3. #3
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Thanks for the quick reply.

    I am currently using this function in my column C. What I need is a statement that will identify if column A or B is a weekend. If this is true, then I need that function to subtract 1 or 2 (if both A and B are weekends) from the total sum in column C.

  4. #4
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Networkdays function is ignored the weekened date. My formula works with your example.

  5. #5
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Correct, the function does ignore weekends, but I also need that function to determine if in fact cell A3 is a weekend date. If A3 is a weekend date, then I need it to subtract 1 from the total. If B3 is a weekend date, I need it to subtract 1 from the total as well. The purpose of this may seem confusing, because it is. Even though its ignoring the weekends, if I have a start date or end date on a weekend, I need that subtracted from the total. Hope this makes sense.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    One way:

    =NETWORKDAYS(A3,B3)-(WEEKDAY(A3,2)>5)-(WEEKDAY(B3,2)>5)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    maybe this:

    =NETWORKDAYS(A3,B3)-(WEEKDAY(A3,2)>5)-(WEEKDAY(B3,2)>5)

  8. #8
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Tony / Mama,

    Thank you for the quick responses. I have used the function provided and it works great. My other question is, can I change a variable in the function to give me a different output in relation to what excel classifies as "weekends"? I understand the number value assigned to each day of the week, so if I were to change the >5 and 2 to >6 and 1, would that change my output?

  9. #9
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Quote Originally Posted by PConn31 View Post
    Tony / Mama,

    Thank you for the quick responses. I have used the function provided and it works great. My other question is, can I change a variable in the function to give me a different output in relation to what excel classifies as "weekends"? I understand the number value assigned to each day of the week, so if I were to change the >5 and 2 to >6 and 1, would that change my output?
    Yes, it will change the output. Try it yourself and find out

  10. #10
    Valued Forum Contributor
    Join Date
    09-15-2011
    Location
    Chennai, India
    MS-Off Ver
    Excel 2010
    Posts
    436

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Try this function.

    The advantage is, if you want modify the weekend as Fri/Sat or Sun/Mon etc, then you can use it as you like.
    Attached Files Attached Files
    Last edited by ramananhrm; 08-22-2013 at 01:04 AM.
    Please click 'Add reputation', if my answer helped you.

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

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    For your original question you can use this formula

    =NETWORKDAYS(A3,B3)-2+NETWORKDAYS(A3,A3)+NETWORKDAYS(B3,B3)

    The last 2 NETWORKDAYS functions evaluate each start and end date and return 1 for a weekday and 0 for a weekend. If you want you can add holiday ranges and also for variable weekends you can use NETWORKDAYS.INTL function in Excel 2010 in place of NETWORKDAYS
    Audere est facere

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    It looks like you're using Excel 2010 with the enhanced NETWORKDAYS.INTL function which allows you to define your own weekend days.

    See Excel help on the NETWORKDAYS.INTL function to see what options you have (and there are many!).

  13. #13
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    I seem to be having another issue here. With this formula - =NETWORKDAYS(C7,D7)-(WEEKDAY(C7,2)>5)-(WEEKDAY(D7,2)>5), if my start date is 8/11 and end date 8/16, it gives me an output of 4 which is correct. The networkdays function automatically ignores the weekend of the 11th and ignores the 16th which is my travel day, perfect. What I need now, is a formula that will recognize the start date or end date as a weekday, and subtract 1 or 2 (if both are weekdays) from the total. Example:

    Start End Total
    8/1 8/10 6 <---correct
    8/11 8/16 4 <---correct
    8/16 8/23 6 <---INCORRECT, using the logic of the others, this should be 4 not 6.
    9/1 9/10 6 <---correct

    For some reason, with certain dates it does not recognize the weekday as being in the start or end position and does not subtract correctly. Thoroughly puzzling that it works 90% of the time. Any ideas?

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

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    This formula......

    =NETWORKDAYS(C7,D7)-(WEEKDAY(C7,2)>5)-(WEEKDAY(D7,2)>5)

    .....is using NETWORKDAYS to count the number of weekdays between C7 and D7 and then the WEEKDAY functions are used to subtract 1 if either C7 or D7 (or both) are weekend days

    If C7 is 16 August 2013 and D7 is 23rd August 2013 then both of those are Fridays so nothing is deducted - the result you get is the same as using the basic NETWORKDAYS formula .....so one Friday to the next will give you 6 (NETWORKDAYS counts both start and end date)

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

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Quote Originally Posted by PConn31 View Post
    What I need now, is a formula that will recognize the start date or end date as a weekday, and subtract 1 or 2 (if both are weekdays) from the total. Example:
    OK, I re-read your last post - initially you wanted to deduct 1 if the start/end dates were weekends, that's what your quoted formula does - now you are talking about deducting 1 for weekdays. Is that a change to your requirement now? If you want to do that then you can change >5 to <6, i.e.

    =NETWORKDAYS(C7,D7)-(WEEKDAY(C7,2)<6)-(WEEKDAY(D7,2)<6)

    but like the first formula you might get some odd results for short date ranges, e.g. if C7 and D7 are the same date (and a weekday) you'd get -2

    If the revised version doesn't work then can you give some more examples of results you want?

  16. #16
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Mr Legs,

    Thank you very much for your responses! I actually figured it out about 10 minutes ago. It's working flawlessly. The other issue I'm having is with my overlap array function. This is my current -

    =SUM(IF(MMULT((WEEKDAY(ROW(INDIRECT(MIN(INT(E5:E24))&":"&MAX(INT(F5:F24)))),2)<6)*(ROW(INDIRECT(MIN( INT(E5:E24))&":"&MAX(INT(F5:F24))))>=TRANSPOSE(INT(E5:E24)))*(ROW(INDIRECT(MIN(INT(E5:E24))&":"&MAX(INT(F5:F24))))<=TRANSPOSE(F5:F24))+0,ROW(E5:E24)^0),1))

    Is there a way I can modify this function to take into account the subtraction of weekdays in the start and end dates? Right now the function is working, but due to the modification of the networkdays function, it's no longer adding properly and adding extra days to the total overlap count. Your help is much appreciated!!

  17. #17
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Here is a snapshot of what my chart looks like...
    Capture.PNG

  18. #18
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    I've think I've exhausted all of my Excel knowledge here. I can get the array to work, but it's still counting weekdays in the start and end columns which is throwing off my total overlap count.

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

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    Assuming that you only have dates in the data (without times) then you don't need all the INT functions in that formula, and you can replace >= with > and <= with < to not consider start and end dates, so revised version would be this:

    =SUM(IF(MMULT((WEEKDAY(ROW(INDIRECT(MIN(E5:E24)&":"&MAX(F5:F24))),2)<6)*(ROW(INDIRECT(MIN(E5:E24)&":"&MAX(F5:F24)))>TRANSPOSE(E5:E24))*(ROW(INDIRECT(MIN(E5:E24)&":"&MAX(F5:F24)))<TRANSPOSE(F5:F24))+0,ROW(E5:E24)^0),1))

    confirmed with CTRL+SHIFT+ENTER

    With that version you should be able to have blanks in the ranges too. I get a result of 15 for your example which I think is correct assuming you don't count dates which are weekdays and only included as either start or end dates of ranges
    Last edited by daddylonglegs; 08-22-2013 at 03:00 PM.

  20. #20
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    You are brilliant, thank you very much!

    One more question for the overlap function. I have a list of excluded holidays I have put into the networkdays function. What modification would I have to make to the overlap function so it excludes the holidays in my range?

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

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    You can add another condition to exclude holidays, e.g. if you have holiday dates in H2:H10 try this version

    =SUM(IF(MMULT((WEEKDAY(ROW(INDIRECT(MIN(E5:E24)&":"&MAX(F5:F24))),2)<6)*(COUNTIF(H$2:H$10,ROW(INDIRECT(MIN(E5:E24)&":"&MAX(F5:F24))))=0)*(ROW(INDIRECT(MIN(E5:E24)&":"&MAX(F5:F24)))>=TRANSPOSE(E5:E24+1))*(ROW(INDIRECT(MIN(E5:E24)&":"&MAX(F5:F24)))<=TRANSPOSE(F5:F24-1))+0,ROW(E5:E24)^0),1))

  22. #22
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    You are the master. I bow to your excel excellence sir. PROBLEM SOLVED!

  23. #23
    Registered User
    Join Date
    10-08-2014
    Location
    India
    MS-Off Ver
    2010
    Posts
    5

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    I have a similar problem.
    My start date is on a holiday.

    please help me with a formula.

  24. #24
    Registered User
    Join Date
    10-08-2014
    Location
    India
    MS-Off Ver
    2010
    Posts
    5

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    I have a similar problem.
    Data: Start date and time in col F, end date and time in col L, lead time (hh:mm:ss) in col M. Lead time calculation formula:=IF(ISBLANK(L2),(NETWORKDAYS(F2,NOW(),Holidays)-1+MOD(NOW(),1)-MOD(F2,1)),(NETWORKDAYS(F2,L2,Holidays)-1+MOD(L2,1)-MOD(F2,1)))
    Lead time is calculated as soon as the start date is entered, considering current time (NOW) as end date until actual end date and time are entered.
    2nd October is in holiday list.

    Issue: For rows with start date as 2nd october, lead time does not give the correct result.
    E.g. start date and time = 02-10-2014 13:56:00 and End date and time = 07-10-2014 12:03.
    Result should be 60:03:00 but I get 46:07:00

    I guess this is because, though 2nd october is considered holiday, start time is calculated from 13:56 and not as 3rd october 00:00

    Hope I have clearly laid the case. Any help appreciated.

  25. #25
    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,939

    Re: NETWORKDAYS with start date, end date, total days - if weekend subtract 1 from total

    skexcelforum , welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    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

+ 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. [SOLVED] Get the total employee per position by entering the start and end date
    By joe41 in forum Access Tables & Databases
    Replies: 4
    Last Post: 03-02-2009, 05:41 AM
  2. Date Function:compute the total number of days
    By MARK XU in forum Excel General
    Replies: 2
    Last Post: 01-09-2006, 05:40 PM
  3. Replies: 4
    Last Post: 10-27-2005, 11:05 AM
  4. Subtract a group of cells from a total based on ending date
    By Nicholas Scarpinato in forum Excel General
    Replies: 0
    Last Post: 05-17-2005, 11:06 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