We help IT Professionals succeed at work.

Year between 2 Years

cpwilson
cpwilson asked
on
371 Views
Last Modified: 2012-06-22
<select name='search_age' size='1'>
	<option value="" selected></option>
	<option value='<cfoutput>#year(now())-1#</cfoutput>'>Kids</option>
	<option value='<cfoutput>#year(now())-13#</cfoutput>'>Teens</option>
	<option value='<cfoutput>#year(now())-20#</cfoutput>'>Twenties</option>
	<option value='<cfoutput>#year(now())-30#</cfoutput>'>Thirties</option>
	<option value='<cfoutput>#year(now())-40#</cfoutput>'>Forties</option>
	<option value='<cfoutput>#year(now())-50#</cfoutput>'>Fifties</option>
	<option value='<cfoutput>#year(now())-60#</cfoutput>'>Sixties</option>
	<option value='<cfoutput>#year(now())-70#</cfoutput>'>Seventies</option>
	</select>
search variable is shown as follows

<cfif search_age is not "">
	and yob BETWEEN year(now()) and #search_age#

</cfif>  

Open in new window

Can anyone help with code to determine if a particular year falls between 2 years? I want to search based on a year field stored in the database (as numeric field) to determine if it is between a generated year (selected as year(now)-13, 20, 30, etc) and today's date. If it is then it should show all records that are between the 2 dates

Search year is taken from a select tag
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
this worked. had to change year(getdate()) to year(now()) as I am using mysql

Author

Commented:
still having an issue with this as it does not now seem to narrow the search down as far as it should.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.