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: Weekdays in a Month.

Weekdays in a Month

by Allen Wyatt
(last updated June 8, 2018)

8

Ever wonder how many of a particular weekday occurs within a given month? For some people, it is important to know how many Tuesdays there are in a month. And who doesn't want to know whether a particular month will have four or five Saturdays?

Excel does not include an intrinsic function that you can use to determine the number of times a particular weekday occurs within a given month. You can, however, create your own formulas and functions to accomplish the task.

First, consider the following formula.

=4+N((WEEKDAY(DATE(YEAR($A$1),MONTH($A$1),1)))+
(DAY(DATE(YEAR($A$1),MONTH($A$1)+1,0))-28)>(7*((
WEEKDAY(DATE(YEAR($A$1),MONTH($A$1),1)))>(1+ROW()-
ROW($A$2)))+(1+ROW()-ROW($A$2))))

The formula relies on a date in A1. This date should be from the month you want "tested." The formula is meant to be copied into a cell in row 2, and then copied to the six cells directly beneath that. For instance, you could copy this formula to the range of cells B2:B8. The first response (B2) is the number of Sundays in the month, the second (B3) is the number of Mondays, and so on.

The drawback to this formula is that it uses the position of the cell containing the formula as part of the formula. This means that the formula must be placed somewhere beginning in the second row.

Another drawback is that the formula is quite long and complex. If you want a shorter formula, then you need to turn to an array formula. One handy formula you can use assumes that you provide three arguments: the year (cell C2), the month (cell D2), and a weekday (cell E2). With these three items, the following formula works great:

=SUM(IF(WEEKDAY(DATE(C2, D2, ROW(INDIRECT("1:" &
DAY(DATE(C2, D2+1, 0))))))=E2, 1, 0))

Remember that this is an array formula, which means that you must enter it by pressing Shift+Ctrl+Enter. In addition, the weekday value you enter in cell E2 must be in the range of 1 through 7, where 1 is Sunday, 2 is Monday, etc.

If your worksheet design doesn't allow for you to enter the year, month, and weekday in different cells, a clean solution is to create a user-defined function to return the count. The following macro is an example of this type of function.

Function MonthWeekDays(dDate As Date, iWeekDay As Integer)
    Dim dLoop As Date

    If iWeekDay < 1 Or iWeekDay > 7 Then
        MonthWeekDays = CVErr(xlErrNum)
        Exit Function
    End If
    MonthWeekDays = 0
    dLoop = DateSerial(Year(dDate), Month(dDate), 1)
    Do While Month(dLoop) = Month(dDate)
        If WeekDay(dLoop) = iWeekDay Then _
          MonthWeekDays = MonthWeekDays + 1
        dLoop = dLoop + 1
    Loop
End Function

You use the function by entering the following in a cell:

=MonthWeekDays(A1,4)

In this usage, the first argument (cell A1) contains a date in the month being evaluated. The second argument is a numeric value representing the weekday that you want to count. This value must be in the range of 1 to 7, where 1 is Sunday, 2 is Monday, and so on.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5684) 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: Weekdays in a Month.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Deriving High and Low Non-Zero Values

When analyzing your numeric data, you may need to figure out the largest and smallest numbers in a set of values. If you ...

Discover More

DOS From Macros

Need to run a DOS command from within one of your macros? The answer is the Shell command, described in this tip.

Discover More

Removing All File Properties

Want to get rid of any properties you've created for a document? You can do so by using the short macro described in this ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Returning Nothing If Two Values are Empty

Excel includes a large number of functions that can be used in evaluating the data in a worksheet. In this tip you learn ...

Discover More

Counting Month Ends

When working with dates in a worksheet, you may need to do some rather esoteric calculations on those dates. This tip ...

Discover More

Calculating a Group Retirement Date

Calculating a retirement date can be as simple as doing some date math to see when a person reaches a certain age. ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 6?

2016-08-13 06:15:41

Michael (Micky) Avidan

Sorry, the previous picture was incomplete.
Here is the correct one:
(see Figure 1 below)
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2017)
ISRAEL


Figure 1. 




2016-08-13 06:12:24

Michael (Micky) Avidan

@Robert Lohman,
The use of: "1101111" has been documented within the NETWORKDAYS.INTL function since it was first launched by MS.
To my opinion the "best & easiest" way (although a little longer formula is to use the presented in the following picture.
It frees you from typing two full dates (in A1, A2).
(see Figure 1 below)
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2017)
ISRAEL


Figure 1. 




2016-08-12 20:21:48

Robert Lohman

I learned this from Mr Excel, Bill Jelen. To find count of Wednesdays in Aug for instance: A1=8/1/16,A2=8/31/16
The following formula works well:
=NETWORKDAYS.INTL(A1,A2,"1101111")
it returns 5 (No. of Wednesdays)
The"1101111" represents MTWTFSS,1 means don't count and 0 means count. Any combination may be used and even Holidays can be added in as a fourth argument.


2014-08-16 05:59:31

Michael (Micky) Avidan

"Small" correction of the Array-Formula:
=SUM(N(WEEKDAY(ROW(INDIRECT(EOMONTH(A1,-1)+1&":"&EOMONTH(A1,0))))=E2))
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2014-08-16 05:13:47

Michael (Micky) Avidan

1) There is no need for an IF check.
The Array Formula can look like:
=SUM(N(WEEKDAY(DATE(C2,D2, ROW(INDIRECT("1:" &DAY(DATE(C2,D2+1, 0))))))=E2))

2) If you provide a full date in cell A1 then the formula will look like:
=SUM(N(WEEKDAY(ROW(INDIRECT(A1&":"&EOMONTH(A1,0))))=E2))

Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2013-07-21 07:58:24

Willy Vanhaelen

When I looked at those formulas I was confused by their complexity and, Leonardo da Vinci's saying "simplicity is the ultimate sophistication" in mind, I thought there had to be a simpler solution. After a while I came up with one. In fact all you have to do is check if a fifth instance of a particular day is still in the same month. This formula for the second approach does that and it has even not to be an array formula:

=IF(MONTH(DATE(C2,D2,1)+35-WEEKDAY(DATE(C2,D2,1)-E2))=D2,5,4)

This formula can be adapted to the first solution:

=IF(MONTH(DATE(YEAR(A$1),MONTH(A$1),1)+35-WEEKDAY(DATE(YEAR(A$1),MONTH(A$1),1)-ROW(A1)))=MONTH(A$1),5,4)

Note that this formula can be entered anywhere in the sheet and copied down 6 rows.

This same formula can even be used in the macro:

Function MonthWeekDays(dDate As Date, iWeekDay As Integer)
If iWeekDay < 1 Or iWeekDay > 7 Then
MonthWeekDays = CVErr(xlErrNum)
Exit Function
End If
dDate = DateSerial(Year(dDate), Month(dDate), 1)
MonthWeekDays = IIf(Month(dDate + 35 - Weekday(dDate - iWeekDay)) = Month(dDate), 5, 4)
End Function


2013-07-20 06:34:36

Rik Smeesters

DateDiff("d";DateSerial([year];[month];1);DateSerial([year];[month]+1;1))-(DateDiff("d";DateSerial([year];[month];1);DateSerial([year];[month]+1;1))-8+Weekday(DateSerial([year];[month];1);2))7-1


2013-07-20 06:26:54

Rik Smeesters

number of non-weekend days in month:
DateDiff("d";DateSerial([year];[month];1);DateSerial([year];[month]+1;1))-(DateDiff("d";DateSerial([year];[month];1);DateSerial([year];[month]+1;1))-8+Weekday(DateSerial([year];[month];1);2))7-1


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.