> 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>

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. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288510
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