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>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288509
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to