weekend, and consequently you need to increment your numDays.
An easy (though not necessarily the best) way to approach the problem is to
make a loop from 1 to the number of days you need. Set a variable to the
start date, and each iteration of the loop add one day. After adding the
day, check the day of the week it's on. If it's a weekend, decrement your
counter variable because even though you added a day, it doesn't count:
<cfscript>
// required variables
startDate = now();
numDays = 5;
// calulate end
endDate = startDate;
for (i = 1; i LTE numDays; i = i + 1) {
endDate = dateAdd("d", 1, endDate);
if (listFind("1,7", dayOfWeek(endDate)) GT 0) {
numDays = numDays + 1;
}
}
</cfscript>
Cheers,
barneyb
> -----Original Message-----
> From: Les Mizzell [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, May 12, 2004 12:51 PM
> To: CF-Talk
> Subject: Next "X" days - but SKIP the weekend....
>
> Afternoon,
>
> Can't quite seem to get my head around this.
>
> I need to show an event list on a site that always list today and the
> next 4 days. But....if any of those days = weekend - it has to SKIP
> those and move on..
>
> So
> Thursday Listing
> Friday Listing
> Monday Listing
> Tuesday Listing
> Wednesday Listing
>
> No problem doing this and *including* the weekend dates.
> Something like:
>
> <cfset now = Now()>
> <cfset enddate = #DateAdd("d", 5, now)#>
>
> Then: show everything equal or less than #enddate# and equal
> or greater
> than today....
>
>
> ....but I'm not sure how to go about skipping dates that fall on
> Saturday or Sunday.
>
> Ideas?
>
> --
> Les Mizzell
> ---------------------------------------
> Do geeks die when exposed to sunlight?
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

