Check whether a date range includes weekends?

Soldato
Joined
31 May 2006
Posts
4,239
Location
127.0.0.1
Hi all

Doing some classic ASP and would like to find out if a date range:

a) Includes any weekends
b) If true return how many weekend days

Thanks for any help!
 
you could use Weekday method to find the first day and calculate manually after that.

i.e if the date is 01/01/2009 and that day is a monday, you know there are 5 days before the weekend etc etc.

Code:
Dim MyDate, MyWeekDay

MyDate = #October 19, 1962#   ' Assign a date.

MyWeekDay = Weekday(MyDate)   ' MyWeekDay contains 6 because MyDate represents a Friday.
 
Last edited:
I managed to sort it. Here is the code if anyone is interested:

Code:
myEndDate = "01/02/2010"
myVarDate = "01/01/2010" ' Start Date

do until myVarDate > myEndDate
	if Weekday(myVarDate) = "7" OR Weekday(myVarDate) = "1" then myWeekends = myWeekends + 1
	myVarDate = dateadd("d",1,myVarDate)
loop

response.write "<br>Number of weekend days: " & myWeekends & "<br>"
 
Back
Top Bottom