I can't do a full algorithm right now, but here is what I woud do for a fast
and dirty solution:
Get the year (Either a Form, URL or default variable)
Loop from 1 to 12 (i)
Get days in Month (GetDaysInMonth() function in
CF) for current index
Loop from 1 to DaysInMonth (j)
> Hope this is a quick and easy one... what would be the simplest way to
> return the dates for every Friday in a given year? (or any other
> particular
> day of the week)
This probably ain't the most elegant or optimized approach, but it works :)
Another pseudo code way to do this...
Set date=Jan 1, yourYear
loop
if DayOfWeek(date)=yourDay then exit loop
date=DateAdd(d,1,yourDate)
end loop
// Assert that date is earlier than Jan 8th
// You have the first date
loop
date=DateAdd(d,7,yourDate)
exit when DatePart(, date) is n
I had to tackle this for my latest project (well, it was every Thursday)
but we ended up writing a DB2 stored procedure and storing the dates in
its own table (the CF is messy, blech). Just about everything the site
does depends on those dates, so it is more efficient for us to use a
separate tab
> Hope this is a quick and easy one... what would be the simplest way to
> return the dates for every Friday in a given year? (or any other
> particular day of the week)
Find the first one, then keep on adding 7 to it - no need to count the days
once you've found the first (a week will always be
5 matches
Mail list logo