> -----Original Message----- > From: Owens, Howard [mailto:[EMAIL PROTECTED] > Sent: Friday, February 28, 2003 6:22 PM > To: CF-Talk > Subject: anybody ever done: every n day of the month for a year ... > > > Just to save me spending too much time trying to figure this out ... > > Anybody already have a code snippet for calculating every N > day of the Month, for a year ... > > Such as, Every 3rd Tuesday of the month? > > That's where I'm at on building my little recurrance engine. > I'll spit the whole code back out the list when it's done, if > anybody wants it. > > H.
I may be over simplifying, but it seems to me that something like the following might work. I'm assuming that that you have a month and year to start: 1) Obtain the number of days in the month using the "DaysInMonth()" function. 2) Loop from the first day of the month to the last day of the month using the "DateAdd()" function to increment the date. 3) For each day use the "DayOfWeek()" function to get the ordinal of the day. 4) Compare the results of DayOfWeek() to your target day and, if it's a match stow the date in an array. At the end of the loop you should have and array of all the dates in the month that fall on the day of week in question. 5) Now you can pluck the needed day directly from the array. Another option would be to genericize this and create a two dimensional array. First dimension would be day of week, second dimension would be dates falling on those days. Then you could pick and choose all you want from the array... Heck, you could even get slightly more complex and create such an array for the whole year. Then you could pluck any value you like at will. Jim Davis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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 This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4