Jeff Waris wrote:

>
> I'd like to loop over a date range in DAYS.
>
>
> Say startdate=06/01/2004 endate=08/06/2004 and have it loop consecutively
> through each day of the month until it gets to the end date.

You just need to use DateAdd and add a day, becuase DateAdd knows how many days are in each month. Then know how many days to loop for, I just  did a datediff from the first date to find that out. You could also use a condition in cfloop but that would probably be less efficent:

<cfset startDate = "06/01/2004">
<cfset endDate = "08/06/2004">
<cfset numDays = DateDiff("d", startDate, endDate)>
<cfset currentDate = startDate+1>
<cfloop from="1" to="#numDays#" index="i">
<cfoutput>#DateFormat(currentDate, "mm/dd/yyyy")#</cfoutput>
<cfset currentDate = DateAdd("d", 1, currentDate)>
</cfloop>

______________________________________
Pete Freitag
http://www.cfdev.com/
Author of the CFMX Developers Cookbook
http://www.petefreitag.com/bookshelf/
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to