Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Specifying Different Weekends with NETWORKDAYS.
by Allen Wyatt
(last updated November 4, 2017)
Sunil can use the NETWORKDAYS function to return the number of regular business days between two dates. The function assumes that Saturday and Sunday are not work days, but in Sunil's organization only Sunday counts as a non-work day. He wonders if there is a way to use NETWORKDAYS and specify that only Sunday should be excluded from the count returned.
You can determine this by using a formula based on the NETWORKDAYS function. Assuming that the starting date is in A1 and the ending date is in B1, the following formula examines the days between the two dates and essentially return a count of non-Sunday days in that range:
Of course, since Sundays are the only day of the week being excluded, you could simply skip the use of NETWORKDAYS and use SUMPRODUCT to figure out if the day should be counted or not:
If you expect that there may be holidays in the range, and that those holidays are in the named range “holidays,” then you'll need to go back to using NETWORKDAYS in the formula:
=NETWORKDAYS(A1,B1,holidays)+SUMPRODUCT(-- (WEEKDAY(ROW(INDIRECT(A1&":"&B1)))=7),-- (NOT(ISNUMBER(MATCH(ROW(INDIRECT(A1&":"&B1)) ,holidays,0)))))
Of course, if you are using the latest versions of Excel (beginning with Excel 2010), you can use the NETWORKDAYS.INTL function, which does more than the older NETWORKDAYS function. The biggest difference between the two is that NETWORKDAYS.INTL allows you to specify how the function should handle weekends. So, for instance, in Sunil's case where only Sundays should be considered "the weekend," you could use the following formula:
Note that the only difference between this and full version of the NETWORKDAYS function is the inclusion of a new third parameter. In this case, the value 11 indciates that only Sundays should be considered weekends, but you could use any other the other parameter values, depending on your needs.
You can perform other magic with NETWORKDAYS.INTL, as well, but that is best left to different ExcelTips.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12450) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Specifying Different Weekends with NETWORKDAYS.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Need to print an elapsed date in a strange format? It's easier to do than may appear at first glance. Here's a discussion ...Discover More
Do you look forward to the weekend? Well, you can use Excel to let you know when the next weekend begins. Here's how you ...Discover More
Want to add an ordinal suffix to a number, as in 2nd, 3rd, or 4th? Excel doesn't provide a way to do it automatically, ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.