|
Greg
you
would better off passing in a value for the time span, as in oler and/or younger
values
So the
form would submit, "I want all people older than 18 and younger that
30"
the
query would look like this
<CFQUERY name="getRecord" dataSource="interact">
SELECT Talent.talentID , Talent.Name , Talent.Gender , Talent.DOB , Talent.Hair , Talent.Eye , Talent.Height , Talent.Clothssize , Talent.shoesize , Talent.hobbies , Talent.BIO , Talent.Compcard , Talent.ID FROM Talent WHERE 1=1 <CFIF ParameterExists(url.ID)>AND Talent.ID = #url.ID#</CFIF> <CFIF ParameterExists(form.search)> AND Talent.gender = '#form.gender#' <!--- Check for age ---> <!--- If we want an age range ---> <CFIF Form.OlderThan AND Form.YoungerThan> AND dob BETWEEN DateAdd(Year,#Form.OlderThan#,dob) AND DateAdd(Year,#Form.YoungerThan#,dob) <cfif> <!--- If we want all people younger than an age ---> <cfif Form.YoungerThan AND NOT Form.OlderThan> AND dob < DateAdd(Year,#Form.YoungerThan#,dob) </cfif> <!--- If we want all people older than an age ---> <cfif NOT Form.YoungerThan AND Form.OlderThan> AND dob > DateAdd(Year,#Form.OlderThan#,dob) </cfif> <CFIF form.hair IS NOT "">and talent.hair = '#form.hair#'</CFIF> </CFIF> </CFQUERY> SQL
has its own DateAdd() function, so dont put and hashes(#) around them in the
query. this way you are making the comparison directly against the DOB
column
See
how you go
Regards Steve Onnis
("If you think it can't be done, you haven't asked me!") - Steve Onnis --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] MX Downunder AsiaPac DevCon - http://mxdu.com/ |
- [cfaussie] Re: look up date by years old with a 2 year spread... stone
- [cfaussie] Re: look up date by years old with a 2 year s... Steve Onnis
- [cfaussie] Re: look up date by years old with a 2 year s... stone
- [cfaussie] Re: look up date by years old with a 2 year s... Steve Onnis
- [cfaussie] Re: look up date by years old with a 2 year s... stone
- [cfaussie] Re: look up date by years old with a 2 year s... Steve Onnis
- [cfaussie] Re: look up date by years old with a 2 year s... stone
- [cfaussie] Re: look up date by years old with a 2 year s... Adam Chapman
- [cfaussie] Re: look up date by years old with a 2 year s... Steve Onnis
- [cfaussie] Re: look up date by years old with a 2 year s... stone
- [cfaussie] Re: look up date by years old with a 2 year s... stone
- [cfaussie] Re: look up date by years old with a 2 year s... Steve Onnis
