Well, for anybody interested ... this is what I have so far in trying to
figure out a way of grabbing the N weekday of the month ... since the
aforemented weekadd didn't work (it doesn't account for five week months), I
thought the best way to proceed would be to try to figure out the first day
of the month, figure out what the first N day is after than, then increment
up weekly after that.

The following code is just draft/development code, not nearly yet production
code ... just thought I would throw it out for comment ... I know I still
have one bug, but can't work on it any more tonight -- I discovered in my
last test that November of this year throws up a first friday with a Date of
0 ... oops!

anyway ... this is what I've done so far ... I'm knocking off the for the
night:

<cfscript>
/* first parse out month of the start date
 * then find out the num val of the day of the week for the start date
 * then grab the year
 * then reconstruct the date to find the day of the week for the first of
the month
 * then add the num val of the recurrence day you want
 * then add the two days together, then subtrack 1 =
 * you now have the date of the first X day of the month
 * then just construct a list by incrementing up by 7 for the month */
 
seedParamWeekDay=6; // this would be a form var for (example) Friday
seedParamWeekRecur=3; // this would be form var for recurrence week
/* calculate the first day name/number of 
 * the month in the seed/start-date month 
 * start date comes from a form var */
seedMonth=month('11/25/03'); // get start-date month
seedYear=year('11/25/03'); // get start-date year
seedDayOWk=DayOfWeek('#seedMonth#/1/#seedYear#'); // rebuild date from start
of the month
seedFirstDay=(seedParamWeekDay-seedDayOWk)+1;

/* build a list of all the days of the month for each week */
week1=seedFirstDay;
week2=week1+7;
week3=week2+7;
week4=week3+7;
last=week4+7;
        /*construct the last date in the weekly recurrence of the month
        * the idea is that the date must be at least less than 31, but since
some months
        * have fewer than 31 days, we still want to make sure we don't wind
up with 
        * something like 2/31/03 */
        if (last LTE 31 or isDate(#seedMonth#/#last#/#seedYear#)) {
                last=last;
        }
        else {
                last=week4;
        }

listmonth = '#week1#,#week2#,#week3#,#week4#,#last#';
schDate=ListGetAt(listmonth, seedParamWeekRecur);

writeoutput('seedParamWeekDay: ');
writeoutput(seedParamWeekDay);
writeoutput('<br> ');

writeoutput('seedParamWeekRecur: ');
writeoutput(seedParamWeekRecur);
writeoutput('<br> ');

writeoutput('seedMonth: ');
writeoutput(seedMonth);
writeoutput('<br> ');

writeoutput('seedYear: ');
writeoutput(seedYear);
writeoutput('<br> ');

writeoutput('seedDayOWk: ');
writeoutput(seedDayOWk);
writeoutput('<br> ');


writeoutput('seedFirstDay: ');
writeoutput(seedFirstDay);
writeoutput('<br> ');



writeoutput('listmonth: ');
writeoutput(listmonth);
writeoutput('<br> ');

writeoutput('last date: ');
writeoutput('#seedMonth#/#last#/#seedYear#');
writeoutput('<br> ');
writeoutput('date: ');
writeoutput(schDate);
</cfscript>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to