Counts occurrences of a weekday between two dates
=LET(
s, start_date+0,
e, end_date+0,
w, weekday_num+0,
first, s + MOD(w - WEEKDAY(s, 2), 7),
IF(first>e, 0, 1 + QUOTIENT(e - first, 7))
)This function counts how many times a given weekday occurs between a start date and an end date, inclusive. Answer questions like "how many Fridays are in this month". For example, if A2 is 2026-01-01, B2 is 2026-01-31, and you want to count Wednesdays (Monday=1, Tuesday=2, etc.), then =COUNT_WEEKDAY_IN_RANGE(A2, B2, 3) returns the number of Wednesdays in January 2026 (4 Wednesdays).
Use the inputs below to create COUNT_WEEKDAY_IN_RANGE as a reusable custom function in Google Sheets.
Learn how to add custom functions to Google SheetsCOUNT_WEEKDAY_IN_RANGE
Counts occurrences of a weekday between two dates
=LET( s, start_date+0, e, end_date+0, w, weekday_num+0, first, s + MOD(w - WEEKDAY(s, 2), 7), IF(first>e, 0, 1 + QUOTIENT(e - first, 7)) )
start_date
end_date
weekday_num
First date in the range (inclusive)
A2
Last date in the range (inclusive)
B2
Target weekday number (Monday=1 ... Sunday=7)
5
Other functions in the same category: Date & Time Operations
Determine if a date falls within a start and end date
Checks if the day and month of a date fall within a date range
Returns TRUE if a date falls on Monday through Friday
Return the next date that matches a weekday number
Return the previous date that matches a weekday number
Returns the weekday name for a given date
Named functions enable the creation of custom, reusable formulas that mimic built-in functions, streamlining calculations and data manipulations. These functions simplify complex formulas, making spreadsheets more readable and less prone to errors. By encapsulating intricate logic within a single function call, they enhance consistency across your data. Utilizing named functions reduces the need to write lengthy formulas repeatedly, thereby improving workflow efficiency and productivity in data analysis and management.
Download and import — fastest way to add the function but does not include argument descriptions and examples
Follow these simple steps to download and import a function into your spreadsheet. This method is the quickest and easiest way to add the named function to your Google Sheets document, but will not include the argument description and examples.
Once added, the function will be ready to use in your document like any other built-in function. Simply type the function name and provide the required inputs to use it in your calculations.
Copy and paste — copy and paste each property one at a time
Follow these simple steps to integrate a custom named function into your spreadsheet:
Once added, the function will be ready to use in your document like any other built-in function. Simply type the function name and provide the required inputs to use it in your calculations.