How can I determine the number of weekends?

# Thread: How can I determine the number of weekends?

1. Member
Join Date
Dec 1969
Posts
41

## How can I determine the number of weekends?

Is there a way to determine the number of weekends (saturday`s and sunday`s) between two dates?<BR><BR>Thanx<BR><BR>Theo

2. Senior Member
Join Date
Dec 1969
Posts
168

## RE: How can I determine the number of weekends?

function countday(bdt,edt,day2count)<BR>if not (isdate(bdt) or isdate(edt)) or datediff("y",bdt,edt) &#060; 0 then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;countday = "Date params were not correct"<BR>else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; countday = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do while bdt &#060;= edt<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;if weekday(bdt) = day2count then countday = countday + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;bdt = dateserial(year(bdt),month(bdt),day(bdt)+1)<BR>&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;loop<BR>end if<BR>end function<BR><BR>&#039;To count Saturday&#039;s in April pass like this:<BR>response.write countday(#4/1/01#,#4/30/01#,vbSaturday)<BR>&#039;To count Sunday&#039;s in April pass like this:<BR>response.write countday(#4/1/01#,#4/30/01#,vbSunday)<BR><BR>Hope this helps... Cheers!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•