Dates

1. Junior Member
Join Date
Dec 1969
Posts
6

## Dates

How to get a count of saturdays and sundays in a given date range . <BR>i.e . no of saturdays and sundays <BR>between 25-01-01 To 26-05-01. <BR><BR>Regards<BR>

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

## RE: Dates

Find out which days of the week those dates fall on (using Weekday()). If on a weekend, increment a counter... then take the number of weeks and multiply by 2 and add to the counter.

3. Senior Member
Join Date
Dec 1969
Posts
151

## Very simple - Check this Desert Ghost

Hello Milly here&#039;s the complete code..<BR>Desert Ghost, don&#039;t give vague answers, check the following code. <BR>&#060;%<BR>dim v_startdate &#039; Variable to hold Start Date<BR>dim v_endate &#039; Variable to hold End Date<BR>dim v_counter &#039; Variable to hold Counter<BR>dim v_placeholder &#039; Variable to hold result of assignment<BR>v_startdate = #January 19, 2001#<BR>v_endate = #February 19, 2001#<BR>for i = v_startdate to v_endate &#039; Loop through the date range<BR> v_placeholder = Weekday(i) &#039; For each iteration assign the weekday to a placeholder<BR> if v_placeholder = 7 Or v_placeholder = 1 then &#039; Test if Saturday or Sunday<BR> v_counter = v_counter + 1 &#039; if true increase the counter<BR> end if<BR>next<BR>response.write v_counter &#039; print the value<BR>%&#062;

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

## Strong disagreement.

First of all, this is the ADVANCED forum. Usually, we do not give CODE here. <BR><BR>Secondly, if there are 937 years between the dates, your method will take FOREVER. DG&#039;s suggested method is *MUCH* better!<BR><BR>Look into the DateDiff function. It&#039;s tons faster than simply counting from now until forever. All you have to do is take care of the "edge" conditions and it does all the work for you.<BR><BR>

#### Posting Permissions

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