+ Reply to Thread
Results 1 to 9 of 9

Formula to count number of days between two dates but skipping specific days of the week

  1. #1
    Forum Contributor
    Join Date
    11-15-2008
    Location
    Arizona
    MS-Off Ver
    Excel 2013
    Posts
    179

    Formula to count number of days between two dates but skipping specific days of the week

    So I have this formula =IF(K3="","",(IF(TODAY()>K3,M3-TODAY()+1,DAYS(M3,K3)+1))) to show the number of days between the range entered in K3 and M3. However, I also need it to not count the days off.

    In the attached workbook on the scheduler page, you can see they have marked Wednesday as their day off. So since there are two Wednesdays between July 1 (the K3 date) and July 14 (the M3 date), L3 (the number of days) should show 12, as it needs to not count Wednesdays in the total days between the range, not 14. (This post was made on June 29. Since it is now past July 1, the number of days shown is no longer 14. But the concept is still the same. I need it to show the amount of days without counting whatever they list as their days off. They can have up to three).

    The main goal here is to get the average number of pages they need to edit a day to finish the project on time, so it needs to reflect the accurate amount of work days they have. If they had two days off (Wednesday and Sunday), then L3 should say 10 since they have four days off in that time frame (again, it is now past July 1, so 10 is no longer the accurate number of days).

    Now cross posted here.
    Attached Files Attached Files
    Last edited by dsrt16; 07-08-2022 at 11:44 PM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Formula to count number of days between two dates but skipping specific days of the we

    Please see yellow banner on how to attach a sample workbook.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Contributor
    Join Date
    11-15-2008
    Location
    Arizona
    MS-Off Ver
    Excel 2013
    Posts
    179

    Re: Formula to count number of days between two dates but skipping specific days of the we

    Sorry I thought image sufficed in showing what I needed. I have now attached my workbook. It is on the Scheduler page that I need help with this formula.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Formula to count number of days between two dates but skipping specific days of the we

    Try

    =IF(OR($K3="",TODAY()> $M3),"",NETWORKDAYS.INTL(MAX(TODAY(),$K3),$M3,LOOKUP($Q4,{"Monday",11;"Friday",15;"Saturday",16;"Sunday",17;"Thursday",14;"Tuesday",12;"Wednesday",13})))

  5. #5
    Forum Contributor
    Join Date
    11-15-2008
    Location
    Arizona
    MS-Off Ver
    Excel 2013
    Posts
    179

    Re: Formula to count number of days between two dates but skipping specific days of the we

    Thank you. That formula is works perfectly for one day off.

    However, I need potentially up to three days off, and I am not sure how to tweak it.


    I tried to tweak the formula to this: =IF(OR($K3="",TODAY()>$M3),"",NETWORKDAYS.INTL(MAX(TODAY(),$K3),$M3,AND(LOOKUP($Q4,{"Monday",11;"Friday",15;"Saturday",16;"Sunday",17;"Thursday",14;"Tuesday",12;"Wednesday",13}),LOOKUP($Q5,{"Monday",11;"Friday",15;"Saturday",16;"Sunday",17;"Thursday",14;"Tuesday",12;"Wednesday",13}))))

    However, it didn't give the right result. I put in Wednesday for first day off (Q4) and Saturday for second day off (Q5). Then I put the project start at July 14 and project end at July 25.

    It returned 8, but it should have returned 9.

    Then the other problem with my tweaked formula is if they do only have one day off and so leave Q5 blank, then the formula returns a #####.I imagine to fix this, I would have to have a bunch of nested if statements. If Q4 is not blank, but Q5 and Q6 are, then use this formula. If Q4 and Q5 are not blank but Q6 is, then use this formula, etc. Or is there any easier way because that would be one super long nested formula.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Formula to count number of days between two dates but skipping specific days of the we

    Post a file with an example of mutiple days off: and can there be more than one project in G3:G6 ?

    If required, would a VBA solution be OK as what is required is set the NETWORkDAYS.INTL "WEEKEND" paramter as a text string indicating non-work days.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Formula to count number of days between two dates but skipping specific days of the we

    Please Login or Register  to view this content.

    above code in sheet "Scheduler 2"


    Please Login or Register  to view this content.
    Code in Module9

    Named range "Weekends" in S3

    in L3

    =IF(OR($K3="",TODAY()> $M3),"",NETWORKDAYS.INTL(MAX(TODAY(),$K3),$M3,weekends))
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    11-15-2008
    Location
    Arizona
    MS-Off Ver
    Excel 2013
    Posts
    179

    Re: Formula to count number of days between two dates but skipping specific days of the we

    Thanks. I have a few questions for my learning.

    What does weekends being set to 0101000 do in S3 do? I am not sure what that means.

    In Module 9's code, the range Days_Off and the range wkdays were never set. How does the code know what cells are in that range?

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Formula to count number of days between two dates but skipping specific days of the we

    Range("Days_Off") ... "Days_Off" is a named range.

    0101000: "1" indicates a non-working day and the string starts from Monday so Tuesday and Thursday are non-working days in this example.

+ 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] Calculating Years, Months, Week, Days, Hours, Minutes for Work Days between two dates
    By hecgroups in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 08-23-2019, 12:09 AM
  2. Count days of week based on dates and specific text
    By elv28 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-20-2018, 01:23 AM
  3. [SOLVED] Adding the correct number of working days to the chart, skipping off days
    By Vitalite in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 07-15-2017, 03:31 AM
  4. [SOLVED] Excel formula to count number of days between sets of dates?
    By barneysplash in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-16-2017, 06:22 AM
  5. [SOLVED] Rounding dates to specific working days of the week
    By Sarah C in forum Excel General
    Replies: 7
    Last Post: 07-13-2016, 12:19 PM
  6. Need formula to count the number days between dates
    By Barieq in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-04-2016, 05:16 PM
  7. Help on count the number of days in between dates and then average number of days
    By Barbara Excel in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-30-2013, 12:13 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