I got an interesting email a little while ago. Here was the problem the reader was having:
I need create a list of years ie 1999-2005 so that I can use them in a loop list, any ideas on how i can achieve this? I have tried using dateformat and subtracting 6, 5 4, 3, 2 and 1 from this year but this just looks ridiculous!
Turns out he had forgotten a simple fact - years are just numbers. What he wanted to do was create a list of years from six years ago to today. You could do this using dateAdd. However, it may be simpler to just use plain old numbers:
<cfset thisYear = year(now())>
<cfset sixYearsAgo = thisYear - 6>
The only time this wouldn't work right is around year 1, but even dateAdd stops working at year 100.
p.s. I haven't done a CF 101 post in a while, but I thought this was a nice and simple post perfect for it. I also hope it tips off my advanced readers that it is something they can probably skip.