You'll be better off converting the target age back to a date and then
search for the date.  That way SQLite can use an index in your query (it
can't use an index when the filter is on an expression).

HTH,

Sam 

-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building
products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
 
-----Original Message-----
From: Allan, Mark [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 03, 2007 6:57 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] Search on Age, from DOB column

Hi,

I need to be able offer the user the ability to search for patients in the
database based on age. i.e. age > 17 or age = 45 etc etc...

I only store the patient DOB in the database however, what is the SQL to
achive this? Can I subract todays date from the DOB and get the number of
years within an SQL string?

The patient table is similar to:-

Patients
{
        INTEGER PrimaryKey;
        TEXT Surname;
        TEXT FirstName;
        TIMESTAMP DOB;
        ...
        ...
        ...
}


Thanks in advance for your help.

Mark


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to