The amazing adventures of Doug Hughes

This was one of those things that I did today expecting it not to work. The problem was that I had a set of dates I needed to iterate over (from a start date to today). I thought to myself, Self, wouldnt it be nice if I could simply loop from the start date to today somehow?

And so, I decided to give it a shot and see what happened. This is the code I tried:

<cfloop from="#Example.getStartDate()#" index="date" to="#now()#">

Much to my amazement it worked. The loop started at the start date (in this case June 15th) and looped up today, one day at a time!

Comments on: "Looping over dates in ColdFusion" (6)

  1. Dont let Gus take the wind out of your sails. You go, date looper guy!!!


  2. Falcon79 said:

    Are there any problems on ColdFusion MX 6.1 or not?


  3. I almost laughed when I seen the code… shit, it actually works! Nice one. Guess we should all RTFM. :p


  4. Even better is if you take advantage of the step parameter. For example:


    will loop you through a range of dates, in 36 hour increments.


  5. 2nd try:



Comments are closed.

Tag Cloud

%d bloggers like this: