I have a table storing a date. I'm trying to calculate when a date is 120 days old, then count how many records have met that criteria. I tried both DATE (YYYY-MM-DD, date("Y-m-d") format and storing it as an 8-character varchar (YYYYMMDD). Regardless of what format I use, the calculations are wrong.
My current code looks like this:
$today = date("Ymd");
$old_date = date('Ymd', strtotime("120 days ago", strtotime($today)));
$odue = 'SELECT * FROM table WHERE ckdate<="$old_date"';
$ores = mysql_query($odue);
$orow = mysql_num_rows($ores);
echo $orow;
Every time it says "0" for $orow even though I know there are some in the table. What am I doing wrong?