Link to home
Start Free TrialLog in
Avatar of Sean Strickland
Sean StricklandFlag for United States of America

asked on

PHP mySQL Select query by date

I'm trying to use the following code to select data by a date range and display it.  I can display it fine, but I can't seem to get the mySQL query right...

$url[3]; is an exploded query_string.  The value is 11/01/08

$searchval = $url[3];
        $itemsbydate = mysql_query("SELECT id,group_number,group_name,date_received,disposition,DATE_FORMAT(date_received,'%Y%m%d') as recdate from inquiries where userid='$userid' and recdate=$searchval");
        while($disprow = mysql_fetch_array($itemsbydate, MYSQL_ASSOC))
      {
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Try like this:
$itemsbydate = mysql_query("SELECT id,group_number,group_name,date_received,disposition,DATE_FORMAT(date_received,'%Y%m%d') as recdate from inquiries where userid='$userid' and date(recdate) = $searchval");

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sean Strickland

ASKER

Thanks!  Both of your solutions combined helped me.