Looping over Date Ranges
On the CF-Talk mailing list today someone asked how to loop over a range of dates, eg from 6/1/04 to 8/6/04. Most people including myself responded that you can use DateAdd and cfloop to do this. But John Beynon posted the simplest solution:
<cfset startDate= "06/01/2004"> <cfset endDate = "08/06/2004"> <cfloop from="#startDate#" to="#endDate#" index="i"> <cfoutput>#dateformat(i, "mm/dd/yyyy")#<br /></cfoutput> </cfloop>
I didn't know you could use dates in the
to attributes of cfloop. I had to try it myself, and sure enough it works. I checked the documentation and I didn't see any mention of it - learn something new everyday.
- Docker Container exited with code 137
- Why is my cron.daily script not running?
- Announcing FuseGuard Version 3
- CFSummit 2017
- Java Unlimited Strength Crypto Policy for Java 9 or 1.8.0_151
- Java 9 Security Enhancements
- Upcoming CFML Conferences in April 2017
- CFSummit 2016 Slides