With the function Work_days() in place, you can get the number of weekend days using this formula:
NumOfWeekendDays
= TotalNumOfDays - NumOfWorkDays
= (EndDate - BeginDate + 1) - Work_days(BeginDate,EndDate)
Let's go about this using a query.
(1) Have you copied and pasted the Work_days() function from the link to a module in your database? You can save the module in any name you like. Remember to add the line in the function to make both dates inclusive.
(2) Create a table with two date/time fields. Name the fields BeginDate and EndDate. Save the table as tblNumOfWeekendDays.
Open the table. Enter a BeginDate and an EndDate.
(3) Create a new query. Copy and paste the following code to the query's SQL View:
SELECT BeginDate, EndDate,
(EndDate - BeginDate + 1) AS TotalNumOfDays,
Work_Days(BeginDate, EndDate) AS NumOfWorkDays,
TotalNumOfDays - NumOfWorkDays AS NumOfWeekendDays
FROM tblNumOfWeekendDays;
Save the query as qNumOfWeekendDays.
(4) Open the query. Edit the BeginDate and EndDate in any way you like in the query. The corresponding NumOfWeekendDays will be displayed in the last column.
Because the Work_days() function does not take care of null values of dates, if you want to use the next row in the query, you must enter two dates in the second row of the table first. Otherwise an error message will pop up.
Hope this helps.