<clip> Your looking at something like. For ages between 21 and 23
$Upper = date("m-d-Y", mktime(0,0,0,date("m"),date("d"),date("y")-22)); $Lower = date("m-d-Y", mktime(0,0,0,date("m"),date("d"),date("y")-23));
$sql = "SELECT field1,field2,field3 FROM `table_name` WHERE `age` BETWEEN " . $Lower . " AND " . $Upper;
$result = myqsl_query($sql);
etc....
Cheers Richard </clip>
Hey Rich, Thanks! That is EXACTLY what I was looking for and instead I got around 10 people sending me a link to the mySql manual's BETWEEN syntax :-)
If you are lucky enough to use MySQL 5 *grin* you can simply do :
SELECT field1,field2 FROM `sometable` WHERE TIMESTAMPDIFF(YEAR,NOW(),`age`) = 22
to find all 22 year olds.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php