Allan, Mark wrote:
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
SELECT * FROM Patients WHERE date('now', '-17 years') > date(DOB);
SELECT * FROM Patients WHERE date('now', '-45 years') > date(DOB) &&
date('now', '-46 years') < date(DOB);
Here you have other time/date functions:
http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions
Paolo
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------