Re: Between Query (0T)
| From: | Richard Collyer | Date: | Sun, 08 May 2005 16:02:33 +0000 |
| Subject: | Re: Between Query (0T) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214708@lists.php.net to get a copy of this message | ||
Ryan A wrote:
On 5/8/2005 5:33:46 PM, Richard Collyer (richard@firebadger.net) wrote: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 FROMRyan A wrote:shouldHi,Sorry I know this is OT but I'm hoping someone will still help...itwantsbe 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 heHey Richard, 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 Thanks, Ryanthe records shown... eg: if he types 23,25 then I should get all results where age >=23 and age <=25 Thanks, RyanWhat are you wanting? An sql query or a form?
table_name WHERE age BETWEEN " . $Lower . " AND " . $Upper;
$result = myqsl_query($sql);
etc....
Cheers
Richard