House of Fusion
Home of the ColdFusion Community

Search cf-talk

October 07, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Subscribe Now
Fusion Authority Quarterly Update - ColdFusion 8 Special Edition
Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Get Next Scheduled Date

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Brian Dumbledore
09/14/2007 04:06 PM

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>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Brian Dumbledore
09/14/2007 04:12 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Brian Dumbledore
09/18/2007 09:23 AM

not even a single reply? Some please confirm that what I ma doing above is the best way to do it? Thanks

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Ben Doom
09/18/2007 09:58 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Brian Dumbledore
09/18/2007 05:58 PM

Thanks for your response. I guess I will just continue with what I have for now.


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists