Help with age and dob in query
Posted: Fri Mar 07, 2008 5:39 pm
Hi all!
Have a few issues with a query I am trying to run on a search page.
Bqsically we have date of births in the database. We want peoeple to be able to browse people in the database of certain ages. So we pass an age range int he URL ans use the GET data to compose the query string
Here is a snippet of the code (it is all in the switch query)
But this will not work as the data is not numeric because of the '-' within the dob format!
I am unsure how I can get this to work?
Any ideas guys?
Thanks
Have a few issues with a query I am trying to run on a search page.
Bqsically we have date of births in the database. We want peoeple to be able to browse people in the database of certain ages. So we pass an age range int he URL ans use the GET data to compose the query string
Here is a snippet of the code (it is all in the switch query)
Code: Select all
$start_date = (date('Y')-22).date('-m-d');
$end_date = (date('Y')-29).date('-m-d');
$search_string .= "AND dob >= '".$start_date."' AND dob < '".$end_date."' ";I am unsure how I can get this to work?
Any ideas guys?
Thanks