I am trying to find all records in the database that fall between the 1st and the last day of the month. So far, it keeps returning zero records. I intentionally put 5 records in the table with dates in this month. It is a Mysql database and the "event_date" field is of the type DATE. All the records are formatted like: 2002-11-05.
On my PHP page, I have this code:
//the $m , $y , and $mNext variables are defined elsewhere in the
//proper 2-digit month and 4-digit year
$MonthStart=date("Y-m-d",mktime(0,0,0,$m,1,$y));
$MonthEnd=date("Y-m-d",mktime(11,59,59,$mNext,0,$y));
mysql_connect (localhost, "user", "password");
mysql_select_db ("db");
$result= mysql_query ("SELECT * FROM cal_events E INNER JOIN
cal_dates D ON (E.event_id = D.event_id) WHERE event_date
BETWEEN ".$MonthStart." AND ".$MonthEnd." ORDER BY
event_date");
When I print $MonthStart and $MonthEnd, they return what would appear to be the correct formatted dates:
2002-11-01 and
2002-11-30
respectively
Yet, I get no records returned. Any ideas on what I'm doing wrong?