Given a start date time, an end date time and a repeat until date time how do I find the same schedule each week until repeat until date time ?
For example:
start date time: 05-29-2012 07:35
end date time: 05-29-2012 10:27
repeat until date: 06-19-2012 09:00
result would be:
06-05-2012 07:35 06-05-2012 10:27
06-12-2012 07:35 06-12-2012 10:27
Any idea how to do that in cfml ?
Here's what I've tried so far:
<cfset start_dt = "05-29-2012 07:35">
<cfset end_dt = "05-29-2012 10:27">
<cfset repeat_until = "06-19-2012 09:00">
<cfoutput>start: #start_dt#<br></cfoutput>
<cfoutput>end: #end_dt#<br></cfoutput>
<cfoutput>repeat until: #repeat_until#<br></cfoutput>
<cfset s_date='#DatePart("m", start_dt)#/#DatePart("d", start_dt)#/#DatePart("yyyy", start_dt)#'>
<cfoutput>#s_date#<br></cfoutput>
<cfset s_date = DateAdd("d", 7, s_date)>
<cfoutput>#s_date#<br></cfoutput>
With your example of expected results, it looks like you don't care about the value of
start_dt
only ofend_dt
. So here is one way that you could make it work. You only need one type of loop, but I've included two so that you can choose your own preference.