Check for Saturday/Sunday

# Thread: Check for Saturday/Sunday

1. ps
Senior Member
Join Date
Dec 1969
Posts
151

## Check for Saturday/Sunday

I am working on a form where a user fills in a "FROM-DATE" and a "TO - DATE"<BR>I would like to run a check and return the number of Saturdays and Sundays present within the "FROM" and "TO" dates entered by the user.<BR>Is it possible to do it in ASP?

2. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Is today a WEEKDAY??

R&D the Weekday function

3. Senior Member
Join Date
Dec 1969
Posts
760

## YES

Today is thursday, thursday is a weekday.

4. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## BRILLIANT you win the prize

Will you choose what is behind door # 1 or door # 2 or door # 3

5. MG Guest

## Here you go

You owe me for this one. It is actually quite simple using some built in vbscript functions. I tested it quickly. Be sure to run your own test using all kinds of different date ranges across years and months. <BR><BR>&#060;%<BR>function cntweekenddates(dt1, dt2)<BR> dim dt, daynbr, x, d, cdt<BR> dt1 = cdate(dt1) &#039convert to date format<BR> dt2 = cdate(dt2) <BR> x = 0<BR> <BR> d = datediff("d", dt1, dt2)<BR> cdt = dt1<BR> <BR> for i = 1 to d + 1<BR> daynbr = Weekday(cdt)<BR> <BR> If daynbr = 1 or daynbr = 7 then<BR> x = x + 1<BR> end if<BR> <BR> cdt = dateadd("d",1,cdt)<BR> next<BR> cntweekenddates = x<BR>end function<BR><BR>response.write cntweekenddates("9/1/2000", "10/31/2000")<BR>%&#062;<BR><BR>

6. ps
Senior Member
Join Date
Dec 1969
Posts
151

## RE: Here you go

MG,<BR>Thanks a lot ! Will test it out sure.<BR>Just let me know where do I send you a six pack. :)

7. MG Guest

## RE: Here you go

Beautiful St. Petersburg, FL

8. Senior Member
Join Date
Dec 1969
Posts
272

## oh NO!..

...can it possibly the Andrew I&#039ve been flaming.<BR><BR>Either way, you have just proved yourself worthy of the title &#039!*&%&%&^\$#%!@!&^#\$&!\$#&\$#&#039.<BR><BR><BR><B R>

#### Posting Permissions

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