RE: anybody ever done: every n day of the month for a year ...
Don't know what you found in the UDF, probably better then what I got, but this is something I created a couple of years ago, that automatically calculates the 2nd Tuesday of the Month for our CFUG meetings. I'll have to look into the UDF at cflib. Ian -Original Message- From: Owens, Howard [mailto:[EMAIL PROTECTED] Sent: Friday, February 28, 2003 3: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. ~~ Howard Owens Internet Operations Coordinator InsideVC.com/Ventura County Star [EMAIL PROTECTED] AIM: GoCatGo1956 ~~ ~| 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
RE: anybody ever done: every n day of the month for a year ...
> -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
Re: anybody ever done: every n day of the month for a year ...
Owens, Howard wrote: >Oops, found a problem with this UDF ... > >It give you the option of feeding in a 5 for the Nth recurrence, which 5, as >I take it, should equal 'last' ... meaning, say, the Last Friday of the >month. Some months that will be the 5th Friday, some months the 4th. > >So for November, for example, the UDF returns -1 instead of the 28th. > > For that you should reverse the UDF, so that it returns the nth day from the end of the month instead of the beginning. Just a thought. Jesse ~| 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 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: anybody ever done: every n day of the month for a year ...
Here, I changed this: //If the result is greater than days in month or less than 1, return -1 if(TheDayInMonth gt DaysInMonth(CreateDate(TheYear,TheMonth,1)) OR TheDayInMonth lt 1){ return -1; } else{ return TheDayInMonth; to this: //If the result is greater than days in month or less than 1, return -1 if(TheDayInMonth gt DaysInMonth(CreateDate(TheYear,TheMonth,1)) OR TheDayInMonth lt 1){ return TheDayInMonth - 7; } else{ return TheDayInMonth; So far, seems to fix it. H. > -Original Message- > From: Owens, Howard [SMTP:[EMAIL PROTECTED] > Sent: Saturday, March 01, 2003 6:50 PM > To: CF-Talk > Subject: RE: anybody ever done: every n day of the month for a year > ... > > Oops, found a problem with this UDF ... > > It give you the option of feeding in a 5 for the Nth recurrence, which 5, > as > I take it, should equal 'last' ... meaning, say, the Last Friday of the > month. Some months that will be the 5th Friday, some months the 4th. > > So for November, for example, the UDF returns -1 instead of the 28th. > > H. > > > > -Original Message- > > From: Cameron Childress [SMTP:[EMAIL PROTECTED] > > Sent: Saturday, March 01, 2003 11:28 AM > > To: CF-Talk > > Subject:RE: anybody ever done: every n day of the month for a year > > ... > > > > Always check CFLib first... > > > > http://www.cflib.org/udf.cfm?ID=179 > > > > -Cameron > > > > > ~| 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
RE: anybody ever done: every n day of the month for a year ...
Oops, found a problem with this UDF ... It give you the option of feeding in a 5 for the Nth recurrence, which 5, as I take it, should equal 'last' ... meaning, say, the Last Friday of the month. Some months that will be the 5th Friday, some months the 4th. So for November, for example, the UDF returns -1 instead of the 28th. H. > -Original Message- > From: Cameron Childress [SMTP:[EMAIL PROTECTED] > Sent: Saturday, March 01, 2003 11:28 AM > To: CF-Talk > Subject: RE: anybody ever done: every n day of the month for a year > ... > > Always check CFLib first... > > http://www.cflib.org/udf.cfm?ID=179 > > -Cameron > > ~| 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
RE: anybody ever done: every n day of the month for a year ...
That's why I come to the list and value the list ... great place to learn stuff. Just wish this time I had learned a little faster :-) H. > -Original Message- > From: Adam Cantrell [SMTP:[EMAIL PROTECTED] > Sent: Saturday, March 01, 2003 5:20 PM > To: CF-Talk > Subject: anybody ever done: every n day of the month for a year ... > > At least you and I learned something. What was I thinking with the > dateAdd+4weeks thing, I've built calendars before and should know better > ;) > > surry bout that. > > Adam. > > ~| 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 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: anybody ever done: every n day of the month for a year ...
Doh! H. > -Original Message- > From: Cameron Childress [SMTP:[EMAIL PROTECTED] > Sent: Saturday, March 01, 2003 11:28 AM > To: CF-Talk > Subject: RE: anybody ever done: every n day of the month for a year > ... > > Always check CFLib first... > > http://www.cflib.org/udf.cfm?ID=179 > > -Cameron > > - > Cameron Childress > Sumo Consulting Inc. > --- > cell: 678-637-5072 > aim: cameroncf > email: [EMAIL PROTECTED] > > > ~| 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
RE: anybody ever done: every n day of the month for a year ...
Always check CFLib first... http://www.cflib.org/udf.cfm?ID=179 -Cameron - Cameron Childress Sumo Consulting Inc. --- cell: 678-637-5072 aim: cameroncf email: [EMAIL PROTECTED] > -Original Message- > From: Owens, Howard [mailto:[EMAIL PROTECTED] > Sent: Friday, February 28, 2003 9:28 PM > To: CF-Talk > Subject: RE: anybody ever done: every n day of the month for a year ... > > > 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: > > > /* 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(' '); > > writeoutput('seedParamWeekRecur: '); > writeoutput(seedParamWeekRecur); > writeoutput(' '); > > writeoutput('seedMonth: '); > writeoutput(seedMonth); > writeoutput(' '); > > writeoutput('seedYear: '); > writeoutput(seedYear); > writeoutput(' '); > > writeoutput('seedDayOWk: '); > writeoutput(seedDayOWk); > writeoutput(' '); > > > writeoutput('seedFirstDay: '); > writeoutput(seedFirstDay); > writeoutput(' '); > > > > writeoutput('listmonth: '); > writeoutput(listmonth); > writeoutput(' '); > > writeoutput('last date: '); > writeoutput('#seedMonth#/#last#/#seedYear#'); > writeoutput(' '); > writeoutput('date: '); > writeoutput(schDate); > > > ~| 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
RE: anybody ever done: every n day of the month for a year ...
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: /* 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(' '); writeoutput('seedParamWeekRecur: '); writeoutput(seedParamWeekRecur); writeoutput(' '); writeoutput('seedMonth: '); writeoutput(seedMonth); writeoutput(' '); writeoutput('seedYear: '); writeoutput(seedYear); writeoutput(' '); writeoutput('seedDayOWk: '); writeoutput(seedDayOWk); writeoutput(' '); writeoutput('seedFirstDay: '); writeoutput(seedFirstDay); writeoutput(' '); writeoutput('listmonth: '); writeoutput(listmonth); writeoutput(' '); writeoutput('last date: '); writeoutput('#seedMonth#/#last#/#seedYear#'); writeoutput(' '); writeoutput('date: '); writeoutput(schDate); ~| 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
RE: anybody ever done: every n day of the month for a year ...
Adam: I had trouble getting this to work with a while loop, so I used a for loop, and what I wind up with is the date of every 4 weeks apart ... if there's a five week month, things get thrown off ... variables.myDate = ArrayNew(1); variables.myDate[1] = "2/28/03"; for (i=1; i LTE 12; i=i+1){ arrayAppend(variables.myDate, DateAdd("ww", 4, variables.myDate[i])); writeoutput('date:'); writeoutput(variables.myDate[i]); writeoutput(""); } H. > -Original Message- > From: Cantrell, Adam [SMTP:[EMAIL PROTECTED] > Sent: Friday, February 28, 2003 3:37 PM > To: CF-Talk > Subject: RE: anybody ever done: every n day of the month for a year > ... > > There may be more efficient means, but if you can supply the initial seed > date - this would work: > > DateAdd(ww, 4, seedDate) > > You would want to put that in a while loop, (while the year remains the > same > as your seed date, add this date to my list). > > Adam. > > > > > -Original Message- > > From: Owens, Howard [mailto:[EMAIL PROTECTED] > > Sent: Friday, February 28, 2003 5: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. > > > > > > ~~ > > Howard Owens > > Internet Operations Coordinator > > InsideVC.com/Ventura County Star > > [EMAIL PROTECTED] > > AIM: GoCatGo1956 > > ~~ > > > > > ~| 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
RE: anybody ever done: every n day of the month for a year ...
There may be more efficient means, but if you can supply the initial seed date - this would work: DateAdd(ww, 4, seedDate) You would want to put that in a while loop, (while the year remains the same as your seed date, add this date to my list). Adam. > -Original Message- > From: Owens, Howard [mailto:[EMAIL PROTECTED] > Sent: Friday, February 28, 2003 5: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. > > > ~~ > Howard Owens > Internet Operations Coordinator > InsideVC.com/Ventura County Star > [EMAIL PROTECTED] > AIM: GoCatGo1956 > ~~ > > ~| 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 Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: anybody ever done: every n day of the month for a year ...
Are you speaking of the RFC? What page? If not, what then and where? H. > -Original Message- > From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED] > Sent: Friday, February 28, 2003 3:33 PM > To: CF-Talk > Subject: Re: anybody ever done: every n day of the month for a year > ... > > Howard, why reinvent the wheel? the ical format specifies all this and > more > WG > Quoting "Owens, Howard" <[EMAIL PROTECTED]>: > > > 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. > > > > > > ~~ > > Howard Owens > > Internet Operations Coordinator > > InsideVC.com/Ventura County Star > > [EMAIL PROTECTED] > > AIM: GoCatGo1956 > > ~~ > > > > > ~| 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
Re: anybody ever done: every n day of the month for a year ...
Howard, why reinvent the wheel? the ical format specifies all this and more WG Quoting "Owens, Howard" <[EMAIL PROTECTED]>: > 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. > > > ~~ > Howard Owens > Internet Operations Coordinator > InsideVC.com/Ventura County Star > [EMAIL PROTECTED] > AIM: GoCatGo1956 > ~~ > > ~| 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 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4