Re: SELECT and DATE issues

From: Date: Thu, 01 Jun 2000 23:08:12 +0000
Subject: Re: SELECT and DATE issues
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-880@lists.php.net to get a copy of this message
> // do the SELECT, using this month's dates > $result = mysql_query("SELECT * FROM events WHERE date between $sd and $ed", > $db); > > > The problem seems to lie with the SELECT query, since the following > works fine: > > $result = mysql_query("SELECT * FROM events WHERE date between > (\"2000-06-00\") and (\"2000-06-31\")", $db); You need to treat $sd and $ed as a string. If you don't have quotes around it SQL will try to find a date between 2000 MINUS 6 MINUS 0 and 2000 MINUS 6 MINUS 31, which is essentially a non existant date. This should work: $result = mysql_query(" SELECT * FROM events WHERE date between \"$sd\" and \"$ed\"", $db); -k

« previous php.general (#880) next »