* Richard Collyer <richard@xxxxxxxxxxxxxx> : > Ryan A wrote: > > On 5/8/2005 5:33:46 PM, Richard Collyer (richard@xxxxxxxxxxxxxx) wrote: > > > Ryan A wrote: > > > > Sorry I know this is OT but I'm hoping someone will still > > > > help...it should be quite simple :-) > > > > I have a field in the database called "age" which is a DATE field. > > > > I also have a webform where the user can select between which > > > > ages he wants the records shown... > > > > eg: if he types 23,25 then I should get all results where > > > > age > =23 and age <=25 > > > > > > What are you wanting? An sql query or a form? > > > > Thanks for replying. > > > > I have the form without a problem, I dont know how to format the SQL > > query... > > the birthdates in the DB are like this: > > > > 12-01-1979 > > 05-03-7955 > > etc > > 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)); Easier than mktime() is strtotime: $upper = date("m-d-Y", strtotime("-22 years")); $lower = date("m-d-Y", strtotime("-23 years")); However... since the OP will be using this in MySQL, use "Y-m-d" as the date format (see the MySQL manual for valid date formats for comparisons). -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association | http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:matthew@xxxxxxxxxx | http://vermontbotanical.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php