First Thursday of month

# Thread: First Thursday of month

1. Senior Member
Join Date
Dec 1969
Posts
11,247

## First Thursday of month

Challenge to find the first Thursday of the month. <BR>Well I thought about it and have created a Function to find the first time a day occurs in any month. <BR>Would like some feedback pls. <BR><BR>&#060;% <BR>Function FirstofMonth(daypart, Mon, Years) <BR>&#039; daypart must be full day as in monday, tuesday etc..<BR>&#039; Mon and Years must be numeric and in range. Years can be 2 or<BR>&#039; 4 digits<BR> Select Case LCase(daypart) <BR> Case "sunday" <BR> datep = VBSunday <BR> case "monday" <BR> datep = VBMonday <BR> Case "tuesday" <BR> datep =VBTuesday <BR> Case "wednesday" <BR> datep = VBWednesday <BR> Case "thursday" <BR> datep = VBThursday <BR> Case "friday" <BR> datep = VBFriday <BR> Case "saturday" <BR> datep =VBSaturday <BR> End Select <BR><BR> firstdayofmonth = Datepart("w", Dateserial( Years, Mon, "1")) <BR> if firstdayofmonth = datep then <BR> FirstofMonth = Dateserial( Years, Mon, "1") <BR> elseif firstdayofmonth &#062; datep then <BR> FirstofMonth = Dateserial( Years, Mon, 8 - (firstdayofmonth - datep) ) <BR> else <BR> FirstofMonth = Dateserial( Years, Mon, 1 + (firstdayofmonth - datep) ) <BR> end if <BR>End Function <BR><BR>test = FirstofMonth("Thursday", 6, 2002) <BR>response.write " <BR>" & formatdatetime(test, vblongdate) <BR>%&#062;

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

## Ah, c'mon....

I saw this yesterday...<BR><BR>you can get this function down to ONE line.... give &#039;er a whirl :)<BR><BR>It&#039;s not as difficult as you think. Try it in one line.

3. Senior Member
Join Date
Dec 1969
Posts
2,854

## crosspost from social...

JK - :-)

4. Senior Member
Join Date
Dec 1969
Posts
7,686

## RE: Ah, c'mon....

http://www.aspmessageboard.com/forum/social.asp?M=507228&T=507170&F=40&P=1

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

## Bite me! <eop>

.

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

## he he

That&#039;s on the lines I was thinking... I wanted to see if WK would&#039;ve given it a try though.<BR><BR>

7. Senior Member
Join Date
Dec 1969
Posts
2,854

## RE: Bite me! <eop>

Dude, I was Just Kidding (JK - :-))

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

## RE: Ah, c'mon....

AS I said in social forum<BR>Type mismatch: &#039;theDay&#039;

9. Senior Member
Join Date
Dec 1969
Posts
2,854

## RE: Bite me! <eop>

i was just winding you up after ChrisQuicks posts in Social.<BR><BR>didn&#039;t mean to offend. sorry

10. Senior Member
Join Date
Dec 1969
Posts
11,247

## I know lol <eop>

I know

#### Posting Permissions

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