I need help with a query. I need to be able to pull dates from current year to last year in the database (so that it can be used by multiple users for my system). I'm trying to populate a select jump menu with dates. I would like to run a query and have it loop through the select feild due to the dates in the database (current year all the way to the earliest year in the database). How in the hell do you do this?
<cfparam name="URL.cDate" default="#Year(Now())#">
<cfset CurrentYear = Year(Now())>
<cfset FourYearsAgo = CurrentYear - 4>/////// or earliest year in database/////////
<form action="#CGI.SCRIPT_NAME#" method="get">
<select name="cDate" id="cDate" onChange="this.form.submit();">
<cfloop from="#CurrentYear#" to="#FourYearsAgo#" index="yearNum" step="-1">
<option value="#yearNum#" <cfif yearNum eq URL.cDate>selected</cfif>>#yearNum#</option>