Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determining # of weekends in a given month

Status
Not open for further replies.

DougInCanada

Technical User
Feb 1, 2004
98
CA
I need a script that can determine if there are 4 Sundays or 5 Sundays in the current month. Can someone help me with this?

Much appreciated.
 
And what have you tried so far ?
Tip: Have a look at the DateSerial and Weekday functions.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Here's what I'm using so far to determine a given on Sunday what weekend of the month it is:


TodaysDate = date()
intWeekDay = WeekDay(TodaysDate)
CurrentDay=day(date())
CurrentMonth=month(date())
CurrentYear=year(date())


If intWeekDay = 7 then
if CurrentDay < 8 Then
strWeekend = "WEEKEND1"
end if

if CurrentDay > 7 and CurrentDay < 15 then
strWeekend = "WEEKEND2"
end if

if CurrentDay > 14 and CurrentDay < 22 then
strWeekend = "WEEKEND3"
end If

if CurrentDay > 21 and CurrentDay < 29 then
strWeekend = "WEEKEND4"
End If

if CurrentDay > 28 then
strWeekend = "WEEKEND5"
End if

End If

What it can't determine is, on the 4th weekend, if there is a 5th weekend for the same current month. I have a script that needs to run on the last weekend of each month. I'm trying to determine from the date of the last day of thge current month, what weekday it is. Something like:

what is the last day of the current month and what weekday does it fall on?

Hope this helps, I'm sort of at a loss for where to start.
 
Tip to get the last day of the month:
LastDay = DateSerial(Year(Now), 1+Month(Now), 0))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Awesome, PHV! Couldn't see the forest for the trees...

Then I just used the Weekday function to determine if it is 7 and if the current day is > 28, then there's a 5th weekend!

Much appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top