+ Reply to Thread
Results 1 to 6 of 6

Counting number of days less weekends.

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Counting number of days less weekends.

    I want to count the number of days between two dates. I am currently using this formula:
    Please Login or Register  to view this content.
    where B1 is equal to a date.

    I want to modify the code to exclude weekends and, if possible, holidays. I don't really care if it excludes holidays but if it can be done great. So for example if:

    2/1/08 = Friday
    2/2/08 = Sat
    2/3/08 = Sun
    2/4/08 = Mon
    2/5/08 = "today"

    then today()-2/1/08 should equal 2 days.

    Thanks for any help.

  2. #2
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Hi,

    Take a look at NETWORKDAYS

    http://www.bettersolutions.com/excel...A111880331.htm
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173
    I like the solution but I can't use it. Our company won't allow users to install add-ins and we don't have admin rights. Any other solutions? Thanks

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Not sure if this helps as I didn't understand your example

    =SUMPRODUCT((WEEKDAY(A1:A17)>=2)*(WEEKDAY(A1:A17)<=6))
    This formula will count number of days excluding weekends

    see link for holiday part

    http://www.excelforum.com/showthread.php?t=608979

    VBA Noob
    Last edited by VBA Noob; 02-29-2008 at 05:52 PM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173
    Looking for a different type of formula. In column A1 is a date...say 2/29/2008. In column B1 is another date...say 2/19/2008. In column C1 I want to calculate the number of days between the A1 and B1. A simple formula to calculate exact number of days would return 10 days. If I exclude Saturdays and Sundays then formula should return value of 8.

    I have attached a spreadsheet of desired results which is in column E to exclude weekends. Column F would exclude weekends and holidays (holiday list is in column H). I prefer a formula to recreate the results in Column F.

    Thanks again for any help.
    Attached Files Attached Files

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    assuming the dates in column B will always be workdays you can use this formula in E3 copied down to exclude weekends

    =SUM(INT((WEEKDAY(B3-{2,3,4,5,6})+A3-B3)/7))-1

    and this formula in F3 to exclude weekends and holidays

    =SUM(INT((WEEKDAY(B3-{2,3,4,5,6})+A3-B3)/7))-SUMPRODUCT((B3<=H$3:H$5)*(A3>=H$3:H$5)*(WEEKDAY( H$3:H$5,2)<6))-1

    Note: if you ever upgrade to Excel 2007 you should be able to use NETWORKDAYS as it's an inbuilt function in that version

+ 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