Try

DateDiff(yyyy,minfo.DOB,GetDate())

-----Original Message-----
From: Angel Stewart [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 11:16 AM
To: CF-Talk
Subject: Date Differences in SQL..


Hi all,

I know this is really simple and I am just missing something
obvious..but what's the syntax for subtracting two dates in SQL? I tried
creating the Query in MS Access and just copying and pasting the code
into CF...but the code that works in Access throws an error in CF.

Here it is:
--------------------------

<CFQUERY name="results" datasource="modelagency" dbtype="ODBC">

        Select  minfo.appdate, minfo.fname, minfo.lname, minfo.mname,
minfo.gender, minfo.dob, minfo.telhome, minfo.telwork, minfo.telcell,
minfo.pager, minfo.address1, minfo.address2, minfo.occupation,
minfo.agent, minfo.height, minfo.weight, minfo.ethnicity,
minfo.skincolor, minfo.talent, minfo.mexp, minfo.comments,
minfo.modelpic,DateDiff("yyyy",minfo.DOB,NOW()) AS AGE FROM minfo

        WHERE 0 = 0

        <CFIF IsDefined("form.fname") AND #form.fname# NEQ "">

                AND fname LIKE '%#form.fname#%'

        </CFIF>

        <CFIF IsDefined("form.lname") AND #form.lname# NEQ "">

                AND lname LIKE '%#form.lname#%'

        </CFIF>


</CFQUERY>
---------------------------

See the date diff thingy at the end there?

-Gel


______________________________________________________________________
Why Share?
  Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to