 Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. 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 Written by Allen Wyatt (last updated April 28, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365

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.

Another great formula you can use is the following:

```=NETWORKDAYS.INTL(DATE(YEAR(A1),MONTH(A1),1),EOMONTH(A1,0),
REPT("1",B1-1) & "0" & REPT("1",7-B1))
```

This generalized formula needs only two values to work properly. The first is a date that is within the month you want to analyze; this goes into cell A1. In cell B1 you should place an indicator of the weekday you want to count. This value is different than in the previous formula—while it must still be in the range of 1 to 7, 1 is Monday, 2 is Tuesday, 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, 2016, 2019, and Excel in Microsoft 365. 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

Inserting a Document's Path

You can use the FILENAME field to insert a document's filename and, optionally, the path to that filename. However, if ...

Discover More

Displaying Path Names in the Menu Bar

Want the full path name for a document visible on the screen? Easily add it to a menu bar.

Discover More

Understanding Styles

Styles are a key concept in Microsoft Word. If you understand styles, you will find it much easier to use Word effectively.

Discover More 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!

##### More ExcelTips (ribbon)

Many businesses need to know when the last business day of the month occurs. This tip discusses several ways you can ...

Discover More

Many businesses organize information according to calendar quarters, especially when it comes to fiscal information. ...

Discover More

Converting an Unsupported Date Format

Excel makes it easy to import information created in other programs. Converting the imported data into something you can ...

Discover More
##### Subscribe

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

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}] (all 7 characters, in the sequence shown) 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 9 + 4?

2023-04-30 04:21:59

Mike J

If you don't mind using a long formula, then this has the slight advantage that it is so easy to adjust the relevant day of the week, and does not need a helper column.

=SUMPRODUCT(N(TEXT(ROW(INDIRECT(DATE(YEAR(A1),MONTH(A1),1)&":"&EOMONTH(DATE(YEAR(A1),MONTH(A1),1),0))),"ddd")="Tue"))

2022-12-05 13:33:53

J. Woolley

The Tip asks how many times a particular weekday occurs within a given month.
My Excel Toolbox includes the following function to return the date of the last weekday of a given month:
=LastWeekdayOfMonth(DayNbr,MonthNbr,YearNbr)
where DayNbr is 1 for Sun, 2 for Mon, ..., MonthNbr is 1 for Jan, 2 for Feb, ..., and YearNbr is a four digit year greater than 1899. For example, the last Sunday in December 2022 is LastWeekdayOfMonth(1,12,2022), which is Christmas Day.
The following LET function formula (Excel 365 and 2021+) is equivalent to LastWeekdayOfMonth:
=LET(EoM,EOMONTH(DATE(YearNbr,MonthNbr,1),0),EoM+1-WEEKDAY(EoM+1-DayNbr))
Combined with Gavin's formula (see comment below), here is the number of times a particular DayNbr occurs within a given MonthNbr and YearNbr:
=CEILING(DAY(LastWeekdayOfMonth(DayNbr,MonthNbr,YearNbr))/7,1)
And here is the equivalent formula using LET:
=LET(EoM,EOMONTH(DATE(YearNbr,MonthNbr,1),0),CEILING(DAY(EoM+1-WEEKDAY(EoM+1-DayNbr))/7,1))

2022-12-04 18:01:40

Gavin

Hi

Many thanks for your help. One of my friends who did maths looked at my problem and suggested:

=CEILING(DAY(A1)/7,1)

This seems to work, don't know why I never thought of it.

Kind Regards Gavin Holt

2022-12-03 14:20:08

Peter Atherton

Gavin Holt

I knew that I'd left something out! The formulas refer to Table. Once the formulas for the lookp list where completed I selected cell in the list and Pressed Ctrl + t. This convertrs the ddata to a table.

Peter

2022-12-03 11:55:00

Peter Atherton

Gavin Holt
You can make a table of dates together with its weekday and week number in adjacent columns. Use a cell to enter the first date of the month I used D2.

In C5:E5 type Dates,, Weekday, Week.
in C6 type = D3, D6 type =Weekday(c6), in E6 type =COUNTIF(\$D\$6:D6,D6)
In C7 type = C6 + 1 and drag this down to C38 this willl have 31 days.

In G3 I entered my Lookup Date - the one to link the formulas to;

Before entering the lookup formulas we need to tweek the end formulas to account for month with less than 31 days.

In D34 change the formula to =IF(C34<=EOMONTH(\$C\$3,0),WEEKDAY(C34),"Next Month") and copy this down.
In E34 change the formula to =IF(ISNUMBER(D34),COUNTIF(\$D\$6:D34,D34),"") and copy this down

Lookup formulas
=VLOOKUP(\$G\$3,Table2,2)&", "&VLOOKUP(\$G\$3,Table2,3)
="Row "&VLOOKUP(\$G\$3,Table2,2)&", Column "&VLOOKUP(\$G\$3,Table2,3)

Hint: if you set up yoour stuff like mine, you can more it around later to a more ideal format for your needs
(see Figure 1 below)
HTH
Peter Figure 1.

2022-12-02 05:49:08

Gavin Holt

Hi,

I am not very good at Excel. In the NHS (UK) we often schedule activity by looking at the columns on a calendar (e.g. All day theatre list Mondays week 1,3,5). This means on the first Monday, third Monday and if present fifth Monday.

When planning, it would be great to have a formula that would accept a date, and return the ordinal of the weekday for that month:

e.g. Jan 2nd 2023 = 1, Jan 28th 2023 = 4, Jan 29 2023 = 5, Jan 30 2023 = 5

Kind Regards Gavin Holt

2020-02-27 08:57:51

Peter Atherton

Darlene
You can convert the months to dates with the following macro - then you can sort them. The macro formats them as text. In future I'd enter a date and format it as "mmm" for short month or "mmmm" for full month.

Sub Txt2Date()
Dim mnth As Integer, yr As Integer
Dim c As Range, x As Variant, i As Integer

x = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
yr = Year(Now())
For Each c In Selection
For i = LBound(x) To UBound(x)
If LCase(Left(c, 3)) = LCase(x(i)) Then
c.value = DateSerial(yr, i + 1, 1)
End If
Next i
Next
Selection.NumberFormat = "mmmm"
End Sub

(see Figure 1 below) Figure 1. Text Converted to date

2020-02-26 11:11:09

Darlene

Hello

Can anyone here please help me? I have been trying to filter months using the filter feature and so far no luck. I can filter the months but they are all mixed up I require them to be in order like January, February etc. I have to include the words Select all and the current year at the top along with the word Blanks at the end. I'm working with a 2016 version of Excel. Any assistance would be greatly appreciated.

2018-11-25 08:10:35

Willy Vanhaelen

Here is a much shorter alternative for the first formula:

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

Note that this formula can be entered anywhere in the sheet and copied down 6 rows provided you adjust the A\$1 reference except for ROW(A1) which can be any reference to row 1 such as ROW(H1).

In the third formula the NETWORKDAYS.INT function is used but this is is only introduced in Excel 2010. Here is an alternative for Excel 2007 and below:

=4+(MONTH(DATE(YEAR(A1),MONTH(A1),1)-WEEKDAY(DATE(YEAR(A1),MONTH(A1),1)-E2)+35)=MONTH(A1))

2018-11-24 10:35:42

Willy Vanhaelen

You don't need a loop in the macro. All you have to do is check if a fifth instance of a particular day is still in the same month. In that case the answer is 5 otherwise it's 4.

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

##### 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.