Calculate Workdays
September 11, 2017 - by Bill Jelen
How many workdays between a start date and an end date? The old functions work for Monday-Friday workweeks, but there are new options for odd work weeks, even Monday, Thursday, Friday, Saturday.
In my live Power Excel seminar, it is pretty early in the day when I show how to right-click the Fill Handle, drag a date, and then choose Fill Weekdays. This fills Monday through Friday dates. I ask the audience, “How many of you work Monday through Friday?” A lot of hands go up. I say, “That’s great. For everyone else, Microsoft clearly doesn’t care about you.” Laughter.
It certainly seems that if you work anything other than Monday through Friday or have a year ending any day other than December 31, a lot of things in Excel don’t work very well.
However, two functions in Excel show that the Excel team does care about people who work odd work weeks: NETWORKDAYS.INTL and WORKDAY.INTL.
But let’s start with their original Monday-Friday antecedents. The following figure shows a start date in B and an end date in C. If you subtract =C5-B5
, you will get the number of days elapsed between the two dates. To figure out the number of weekdays, you would use =NETWORKDAYS(B2,C2)
.
It gets even better. The old NETWORKDAYS allows for an optional third argument where you specify work holidays. In the next figure, the list of holidays in H3:H15 allows the Work Days Less Holidays calculation in column F.
Prior to Excel 2007, the NETWORKDAYS and WORKDAY function were available if you enabled the Analysis ToolPak add-in that shipped with every copy of Excel. For Excel 2007, those add-ins were made a part of the core Excel. Microsoft added INTL versions of both functions with a new Weekend argument. This argument allowed for any two consecutive days as the weekend and also allowed for a one-day weekend.
I’ve seen a manufacturing plant switch to six day weeks in order to meet excess demand.
Plus, there are several countries with weekends that don’t fall on Saturday and Sunday. All of the countries shown below except Bruneei Darussalem gained functionality with NETWORKDAYS.INTL and WORKDAY.INTL.
However, there are still cases where the weekend does not meet any of the 14 weekend definitions added in Excel 2007.
I happen to live in the same county as the Pro Football Hall of Fame in Canton, Ohio. But the top tourism destination in our county is not the hall of fame. The top tourism destination is the Hartville Marketplace and Flea Market. Started in 1939, this place is a hot spot for people looking for fresh produce and bargains. The original lunch stand became the Hartville Kitchen restaurant. And the nearby Hartville Hardware is so big, they built an entire house inside the hardware store. But the Marketplace is the beneficiary of the new, secret weekend argument for NETWORKDAYS and WORKDAY. The Marketplace is open Monday, Thursday, Friday, and Saturday. That means their weekend is Tuesday, Wednesday and Sunday.
Starting in Excel 2010, instead of using 1-7 or 11-17 as the weekend argument, you can pass a 7-digit binary text to indicate if a company is open or closed on a particular day. It seems a bit unusual, but you use a 1 to indicate that the store is closed for the weekend and a 0 to indicate that the store is open. After all, 1 normally means On and 0 normally means Off. But the name of the argument is Weekend, so 1 means it is a day off, and 0 means you don’t have the day off.
Thus, for the Monday, Thursday, Friday, Saturday schedule at the Hartville Marketplace, you would use "0110001". Every time I type one of these text strings, I have to silently say in my head, “Monday, Tuesday, Wednesday...” as I type each digit.
Marion Coblentz at the Hartville Marketplace could use the following formula to figure out how many Marketplace days there are between two dates.
By the way I did not use the optional Holidays argument above because Memorial Day, July 4, and Labor Day are the biggest customer days in Hartville.
If you are ever in northeastern Ohio, you need to stop by Hartville to see the 100% American-Made house inside of the Hartville Hardware and to try the great food at the Hartville Kitchen.
Watch Video
- Date math in Excel: Subtract earlier date from later date + 1
- To ignore weekends, use NETWORKDAYS function
- To not count holidays, use the 3rd argument in NETWORKDAYS
- For non-standard weekends, use NETWORKDAYS.INTL
- Secret 7-binary digit code for work weeks that are not consecutive days
- Alt + E S F for Paste Special Formulas
Video Transcript
Learn Excel from MrExcel podcast, episode 2023 - Calculate Workdays, Even for Non-Standard Workweeks!
I'll be podcasting this entire book, click the “i” on the top-right hand corner to get to the playlist!
Hey, welcome back to the MrExcel netcast, I'm Bill Jelen. So I talked about this feature back in episode 1977 for Fill Week Days. You right-click the fill handle, drag and when you let go, you choose Fill Weekdays, and you see that it fills Monday-Friday. Works great for a lot of countries in the world, but there's countries in the world where the weekend is not Saturday-Sunday, right? And just sorry, Microsoft Excel doesn't care about you, alright! So, we're going to talk about how to calculate the number of workdays between two dates, and we just need to know the number of days between two dates. We take the later date minus the earlier date +1, and you'll see how many work days there are, right, that works great if you work every day, right? But if you want to leave out the weekends, the Saturdays and Sundays, =NETWORKDAYS has been around while in the Analysis tool back, you know, a long time, it became an official part of Excel in Excel 2007.
So you specify the start date, comma, the end date, ), and that throws out the Saturdays and Sundays alright, it's still a problem, though, because it's counting holidays. If we want to leave out the holidays, then we use =NETWORKDAYS from the start date to the end date, comma, and then an optional argument where the holiday is. So I'll choose that, I'll press F4 to lock that down, and it will calculate the number of workdays less holidays, alright. So now let's calculate this for all of these, will copy this down and say Fill Without Formatting, and you'll see that here there are 351 days, 251 days if you throw out Saturdays and Sundays, but 239 days if you threw out all of these holidays, right, great, great function.
IF you're in the United States or actually, if you're not in any of the countries listed in rows 2-6, all of these countries, your weekend is Friday and Saturday, Nepal Saturday, Afghanistan Thursday and Friday, here on Iran only Friday. And then the completely evil one that will be difficult to deal with is Brunei, I had to go figure out where Brunei is! Is it true your weekend is Friday and Sunday? How miserable is that, right? I don't know, it's a one day work week, I guess, I don't know, anyway, alright. So what if you have to calculate a weekend that's not Saturday and Sunday?
Here’s a manufacturing plant that's working Monday through Saturday, so their only work day off is Sunday, well, I think it was Excel 2010 they gave us =NETWORKDAYS.INTL! Starts out the same, here’s the start date, here's the end date, and then the new third argument, we get to specify what the weekend is, and in this case it will be Sunday-only. It still isn't going to handle Brunei where it's Friday and Sunday, but for any other two consecutive days or one consecutive day, there's an option for that now. And then the holidays out here, press F4, and you have your answer. I'll do Alt E S F or Paste Special Formulas, Enter, and we can copy that one down, alright. Now, how a leopard died(?), or just anything that is a non-standard work week. Back in the day, barbershops used to be closed on Sundays and Wednesdays. I used to live up in Ohio, and we'd go shopping at the Hartville marketplace, the flea market, this place, wonderful place. By the way, if you're there to see the Pro-Football Hall Of Fame, just 20 minutes up the road, they're open Monday, Thursday, Friday and Saturday, right?
So their weekend then is Tuesday, Wednesday, something, how are we ever going to do that with a NETWORKDAYS? Well, this is so cool, they've added this crazy new option that’s not documented in the tooltip. So NETWORKDAYS.INTL, here's the start date, comma, here's the end date, comma, and then the secret one that's not here in the dropdown at all is, in quotes, 7 binary digits! 0’s and 1’s, starting with a Monday, 1 means it's a weekend, 0 means it’s open. So the Hartville marketplace, they're open on Mondays, so put a 0, they're closed on Tuesday and Wednesday, they're open on Thursday, Friday, Saturday, they're closed on Sunday, close the quotes. Holidays, I don't know, there are no holidays at this place because, frankly, if the 4th of July falls on a Monday or a Thursday, THAT's their biggest day, everyone is off from working, so they all go flying in that place, it’ll be tough to get a parking spot. Alright so, the actual number of workdays between those two dates, I’ll right-click and Fill without Formatting, alright, I love this one kind of secret.
If you go to Excel help, you'll find it, but if you're just looking the tooltip, you will never know it's there unless, of course, you own this book. And on page 99 you read about it, or if you saw this video, so either way, cool. click the “i” on the top-right hand corner to buy the book, $10 is an e-book, $25 for the print book, all of these amazing tips, 2.5 months’ worth of podcast, all on the palm of your hand. Alright, date math in Excel, subtract the earlier date from the late +1, that counts out Saturdays and Sundays. To ignore weekend’s use the NETWORKDAYS function to not count holidays, you would use the third argument at NETWORKDAYS, make sure to press F4 for that. For non-standard workweeks, NETWORKDAYS.INTL, that allows for any 2 or 1 consecutive weekend. And then there's a secret 7-binary digit code for workweeks that are not consecutive days, even in the country of Brunei, you'd be able to handle that Friday and Sunday workweek.
Well hey, I want to thank you for stopping by, we'll see you next time for another netcast from MrExcel!
Download File
Download the sample file here: Podcast2023.xlsx
Title Photo: market-stand-vegetables-variety / pixabay