select mondays only

# Thread: select mondays only

1. Junior Member
Join Date
Dec 1969
Posts
22

## select mondays only

Given the following function to get the number of days in each month, how can I display the date for Mondays ONLY in each month? Can someone help me?<BR> <BR>Function GetDaysInMonth(dMonth, dYear)<BR> Select Case dMonth<BR> Case 1, 3, 5, 7, 8, 10, 12<BR> GetDaysInMonth = 31<BR> Case 4, 6, 9, 11<BR> GetDaysInMonth = 30<BR> Case 2<BR> If IsDate("February 29, " & dYear) Then<BR> GetDaysInMonth = 29<BR> Else<BR> GetDaysInMonth = 28<BR> End If<BR> End Select<BR>End Function

2. Kentium Guest

## hmmm...

Seems like you&#039;d need a starting point...<BR><BR>Maybe use GetDate or Now to figure out what day of the week it is today, and use that as your reference.<BR><BR>I guess that&#039;s how i&#039;d start off.

3. Senior Member
Join Date
Dec 1969
Posts
1,175

## RE: select mondays only

&nbsp;<BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctweekday.asp<BR><BR>this ought to help.<BR><BR>I would do a nest for loop<BR>for i = 1 to 12<BR> for j = 1 to Datediff("d",&#039;i/1/year&#039;,&#039;i+1/1/year&#039;) <BR> then use the func above with some basic logic<BR><BR> for j = 1 to end of month <BR>

4. Senior Member
Join Date
Dec 1969
Posts
11,334

## Homework assignment?

"Given the following function" ??? Sounds like an assignment.<BR><BR>I just seen this code on MSDN yesterday... what do you need it for?<BR><BR>For i = 1 to 12<BR> For j = 1 to GetDaysInMonth(i, 2002)<BR> If Weekday(CDate(i & "/" & j & "/" & 2002)) = vbMonday Then<BR> &#039;it&#039;s a Monday<BR> End If<BR> Next<BR>Next<BR><BR><BR>Not the most efficient, but I&#039;m gettin&#039; lazy right now....

5. Senior Member
Join Date
Dec 1969
Posts
11,334

## Wow am I late with this <nm>

boo

6. Junior Member
Join Date
Dec 1969
Posts
9

## RE: select mondays only

Dim dMonth, dYear, dDay<BR>Dim iMaxDays<BR>dMonth = 1<BR>dYear = 2002<BR>iMaxDays = GetDaysInMonth(1, 2002)<BR><BR>Response.Write "Mondays in " & MonthName(dMonth) & "<BR>"<BR>For dDay = 1 To iMaxDays<BR> <BR> If DatePart("W", dMonth & "/" & dDay & "/" & dYear) = vbMonday Then<BR> Response.Write dMonth & "/" & dDay & "/" & dYear & "<BR>"<BR> End If<BR>Next<BR><BR>Function GetDaysInMonth(dMonth, dYear) <BR> Select Case dMonth<BR> Case 1, 3, 5, 7, 8, 10, 12 <BR> GetDaysInMonth = 31 <BR> Case 4, 6, 9, 11 <BR> GetDaysInMonth = 30 <BR> Case 2 <BR> If IsDate("February 29, " & dYear) Then <BR> GetDaysInMonth = 29 <BR> Else <BR> GetDaysInMonth = 28 <BR> End If <BR> End Select <BR>End Function

7. Senior Member
Join Date
Dec 1969
Posts
1,175

## getting lazy?

getting? that would imply you are not normally.<BR><BR>&#062;GetDaysInMonth(i, 2002)<BR>I can say I have never seen this function before.<BR>why would they publish such a thing?<BR><BR>how bout dem Eagles? Packers?

8. Senior Member
Join Date
Dec 1969
Posts
11,334

## Heh

No, I meant the GetDaysInMonth -- I ran into it yesterday searching billions of web pages.<BR><BR>Eagles destroyed the Bucs as I expected. I thought GB would pull though, just didn&#039;t think it would&#039;ve been that close &#060;well, until the last few minutes&#062;.<BR><BR>Only suprise is Miami lost...<BR><BR>GB vs STL? Sorry... I think the Rams are gonna go. Bears may beat the Eagles -- hopefully the bye week slowed &#039;em down.<BR><BR>Where&#039;ve you been latelY?

9. Junior Member
Join Date
Dec 1969
Posts
22

## RE: Homework assignment?

nope, sounds like it though. trying to create an event calendar, but only want users to post on mondays. thanks.

10. Senior Member
Join Date
Dec 1969
Posts
1,175

## RE: Heh

Hmm<BR><BR>I thought the Pack would have been a bit stronger, first half was real slow.<BR><BR>I think the Pack have a 30% chance of winning. Reason? Ahman Green/Brett Favre. They could have potentially great days against the defense. The pack is real poor on turf though, Atlanta even beat them (on turf).<BR><BR>Eagles, not sure of what will happen there, I think anything, McNabb is darn good, but Urlacher is a force. He might clean the clock. That should be one of the better games.<BR><BR>go Bears (in case the Packers win, it will be at Soldier field and it should be -10 degrees by then.

#### Posting Permissions

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