Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Box Date

Status
Not open for further replies.

ewylam

Programmer
Jan 25, 2005
16
US
How can I have selection boxs within a form only show dates that are in between two dates pulled from a database? Any suggestions?
 
you tell your query to only bring back the dates you want.

<cfquery name = "qListDates" datasource = "yourDataSource">
SELECT yourDate
FROM tableName
WHERE yourDate bewteen ##1/1/04## and ##1/1/05##
</cfquery>

notice the ## you need them to tell cf you only want one real # there. date fields are often wrapped in #'s

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Is this the sort of thing you are looking for:

Code:
<CFSET Request.DateStart = "12/12/2004">
<CFSET Request.DateEnd = "12/25/2004">


<select name="StartDay">
<CFLOOP FROM="#Day(Request.DateStart)#" TO="#Day(Request.DateEnd)#" INDEX="i">
	<option value="<CFOUTPUT>#i#</CFOUTPUT>"><CFOUTPUT>#i#</CFOUTPUT></option>
</CFLOOP>
</select>

<select name="StartMonth">
<CFLOOP FROM="#Month(Request.DateStart)#" TO="12" INDEX="i">
	<option value="<CFOUTPUT>#i#</CFOUTPUT>"><CFOUTPUT>#i#</CFOUTPUT></option>
</CFLOOP>
</select>

<select name="StartYear">
<CFLOOP FROM="#Year(Request.DateStart)#" TO="#Year(Request.DateEnd)#" INDEX="i">
	<option value="<CFOUTPUT>#i#</CFOUTPUT>"><CFOUTPUT>#i#</CFOUTPUT></option>
</CFLOOP>
</select>
<BR><BR><BR><BR>
<select name="EndDay">
<CFLOOP FROM="#Day(Request.DateStart)#" TO="#Day(Request.DateEnd)#" INDEX="i">
	<option value="<CFOUTPUT>#i#</CFOUTPUT>"><CFOUTPUT>#i#</CFOUTPUT></option>
</CFLOOP>
</select>

<select name="EndMonth">
<CFLOOP FROM="#Month(Request.DateEnd)#" TO="12" INDEX="i">
	<option value="<CFOUTPUT>#i#</CFOUTPUT>"><CFOUTPUT>#i#</CFOUTPUT></option>
</CFLOOP>
</select>

<select name="EndYear">
<CFLOOP FROM="#Year(Request.DateEnd)#" TO="#Year(Request.DateEnd)#" INDEX="i">
	<option value="<CFOUTPUT>#i#</CFOUTPUT>"><CFOUTPUT>#i#</CFOUTPUT></option>
</CFLOOP>
</select>

Hope this helps!

Tony
 
Awesome Tony. Thanks alot that was perfect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top