Determining last, first, second, third...

# Thread: Determining last, first, second, third...

1. Join Date
Dec 1969
Posts
1,969

## Determining last, first, second, third...

How is it possible to determine the,<BR><BR>first, second, third, fourth, and last...<BR><BR>Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday..<BR><BR>of a given month?

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

## RE: Determining last, first, second, third...

Sure it is, but I don&#039;t think the intention of this forum is to spoonfeed you, do you?<BR><BR>look at the different date functions, such as DATESERIAL, DATEPART etc. The link to the VBScript reference is on the left of this page.<BR><BR>If you search this forum, there have been posts on how to determine the first day of the month, once you have that the rest is relatively easy.

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## RE: Determining last, first, second, third...

Let&#039;s see...<BR><BR>&#060;%<BR>theYear = 2003 &#039; or get it from a Request.Form or whatever<BR>theMonth = 11<BR><BR>firstOfMonth = DateSerial( theYear, theMonth, 1 )<BR>lastOfMonth = DateSerial( theYear, theMonth+1, 0 )<BR>%&#062;<BR><BR>So far, so good...all the basic easy stuff, no?<BR><BR>But now we want the first SOMEDAY of month, where SOMEDAY is 1 (for Sunday) thru 7 (for Saturday). Or, in VBS terms, where SOMEDAY is vbSunday to vbSaturday.<BR><BR>I guess an easy way to do it:<BR><BR>&#060;%<BR>dt = firstOfMonth<BR>Do Until WeekDay(dt) = SOMEDAY <BR> dt = dt + 1<BR>Loop<BR><BR>&#039; so now dt is equal to the date of the first SOMEDAY of that month<BR>wk = 1<BR>Do Until dt &#062; lastOfMonth<BR> Response.Write WeekdayName(SOMEDAY) & " number " & wk _<BR> & " in " & MonthName(theMonth) & ", " & theYear _<BR> & " is " & dt & "&#060;br/&#062;"<BR> dt = dt + 7<BR> wk = wk + 1<BR>Loop<BR>%&#062;<BR><BR>How&#039;s that?<BR><BR>Just set theYear, theMonth, and SOMEDAY to the values you want and that will give you your answers.<BR><BR><BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## LOL! One spoonfeeder, coming up...

You&#039;re right. He should have been able to get that one himself.<BR><BR>Oh, well. It was late and time to go to bed, anyway.<BR><BR>

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

## heh

I thought you would have gone to bed already :)<BR><BR>Good night!<BR><BR>

6. Join Date
Dec 1969
Posts
1,969

## thats a start...

thanks Bill...<BR><BR>it was an interesting read. I guess I should know better than to ask such bland questions.<BR><BR>John ;-)

7. Join Date
Dec 1969
Posts
1,969

## actually...

I was having some difficulty in determining the first *weekday* of the month. Ill have a go at this tonight.<BR><BR>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
•