How about "SELECT * FROM table WHERE date >= '$startdate' AND date <= '$enddate'"; You can then define startdate and enddate depending on whether you want a date earlier later or the same i.e. if the same then make startdate and enddate the date you want, if earlier then make the startdate blank, etc.
Tim Ward Internet chess www.chessish.com <http://www.chessish.com> ---------- From: Craig Westerman [SMTP:[EMAIL PROTECTED]] Sent: 25 February 2002 19:32 To: Lerp Cc: [EMAIL PROTECTED] Subject: RE: [PHP] Re: php - assigning date variables Joe, I don't want to change the query itself like you show. I want to use this query $query = "????" mysql_query("SELECT * FROM table WHERE date LIKE '%". $query ."%'"); and change only the variable $query = "????" I use $query throughout script for other things. Thanks Craig ><> [EMAIL PROTECTED] Hi there :) 1. mysql_query("SELECT * FROM table WHERE date ='$mydate'"); # where date is same 2. mysql_query("SELECT * FROM table WHERE date > '$mydate'"); # where date is newer 3. mysql_query("SELECT * FROM table WHERE date < '$mydate'"); # where date is older 4.mysql_query("SELECT * FROM table WHERE date BETWEEN '$myfirstdate' AND '$myseconddate'"); # where date is between 2 dates Hope this helps, Joe :) "Craig Westerman" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > $query = "" > mysql_query("SELECT * FROM table WHERE date LIKE '%". $query ."%'"); > // returns all items in database > > > $query = "2001-01-01" > mysql_query("SELECT * FROM table WHERE date LIKE '%". $query ."%'"); > // returns all rows that have 2001-01-01 as the date > > > What is proper way to define a variable to include all dates newer than > 1995-01-01? > $query = "???" > > What is proper way to define a variable to include all dates older than > 1995-01-01? > $query = "???" > > What is proper way to define a variable to include all dates between > 1995-01-01 and 1998-12-31? > $query = "???" > > > Everything I tried gives me a error. This has to be simple, but I must be > overlooking something. Where would I find the answer? > > Thanks > > Craig ><> > [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php