|
Thank you Steve for your query. Looks like the way
to go..
i have an error with an if tag in the
query
<CFIF Form.OlderThan AND
Form.YoungerThan>
is it mssing some () or ParameterExists
functions?
Also ill format the date like this
.
<cfset form.olderthan = "{d
'1997-12-31'}">
<cfset form.youngerthan = "{d '1997-12-31'}"> Is this correct?
<cfset from.search = "yes"> <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> ERROR
The tag is not correctly positioned relative to other tags in the template: tag CFIF must have some content. This means that there must be at least one tag, some text, or even just whitespace characters between the <CFIF> and </CFIF> markers. This problem may be due to a CFML comment that has no end comment mark. The error occurred while processing an element with a general identifier of (CFIF), occupying document position (32:1) to (32:35).
Greg stone ----- Original Message -----
From: Steve Onnis
Sent: Wednesday, March 19, 2003 12:41 AM
Subject: [cfaussie] Re: look up date by years old with a 2 year
spread < 2 > 2 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/ --- 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
- [cfaussie] Re: look up date by years old with a 2 year s... stone
