|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Get Next Scheduled Date
Didnt' how else to put in the subject. Here is the scenario.. Given a date, say you have to calculate the corresponding date in the next month, 'corresponding' as in, if 'theDate' is say third wednesday, then 'finalDate' should be third wednesday of next month. I think you got the idea.Brian Dumbledore 09/14/07 04:06 P > Didnt' how else to put in the subject. Here is the scenario.. Given aBrian Dumbledore 09/14/07 04:12 P not even a single reply? Some please confirm that what I ma doing above is the best way to do it? ThanksBrian Dumbledore 09/18/07 09:23 A I've had to calculate "first Tuesday" and "every other thursday" etc.Ben Doom 09/18/07 09:58 A Thanks for your response. I guess I will just continue with what I have for now.Brian Dumbledore 09/18/07 05:58 P Didnt' how else to put in the subject. Here is the scenario.. Given a date, say you have to calculate the corresponding date in the next month, 'corresponding' as in, if 'theDate' is say third wednesday, then 'finalDate' should be third wednesday of next month. I think you got the idea. Ofcourse we cann't do this for 'extra' days like the 'fifth' ones, but for all reasonable dates we should be able to. Below is what I wrote.. and it works ( I think..) I WANT TO KNOW IF THERE IS ANY BETTER/CONCISE WAY of doing this. Please help. <cfparam name="theDate" default="09/16/2007"> <cfset fDate=CreateDate(Year(theDate),Month(theDate),1)> <cfset nmfDate=dateadd("m",1,fDate)> <cfset ddiff=(dayofweek(fDate)-dayofweek(nmfDate))> <cfset finalDate=dateadd("d",ddiff,dateadd("m",1,theDate))> <cfif Month(finalDate) eq Month(theDate)> <cfset finalDate=dateadd("d",-2*ddiff,finalDate)> </cfif> <cfoutput>#theDate# is a #DayofWeekasString(DayofWeek(theDate))#</cfoutput><br> <cfoutput>#finalDate# is a #DayofWeekasString(DayofWeek(finalDate))#</cfoutput> ----- Excess quoted text cut - see Original Post for more ----- I realized I don't really have to take the 'first day' of the months to get the diff, I can just add one month to the given date dateadd('m',..) and get the diff. So what better way is there. not even a single reply? Some please confirm that what I ma doing above is the best way to do it? Thanks I've had to calculate "first Tuesday" and "every other thursday" etc. There isn't a really clean way to do it that I found. I ended up doing a bit of math on day(date) and the number of days in a month. I'm not sure if your way is better or not. --Ben Doom Brian Dumbledore wrote: > not even a single reply? Some please confirm that what I ma doing above is the best way to do it? Thanks Thanks for your response. I guess I will just continue with what I have for now.
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||