I'm trying to limit the results of a query to database entries entered less than a week ago. Here is my select statement:
$result = mysql_query("SELECT * FROM `outage` where status='resolved' or status='clear' or status='cleared' order by ID");
In order to get my cut off date, I use this bit:
$timestamp = time();
$newstamp = $timestamp-604800;
That subtracts a week from the current date, giving me the date of one week ago. The problem I'm having is inserting that information into my select statement. My date is stored in my table as just mm/dd. How can I do the comparison in the select statement to get a valid result? I've tried this:
$timestamp = time();
$newstamp = $timestamp-604800;
$date = date("m/d", $newstamp);
$result = mysql_query("SELECT * FROM `outage` where status='resolved' or status='clear' or status='cleared' and date >= $date order by ID");
When I just echo $date, I get a result of 06/05, but the table still shows results with dates older than that. I've tried backticks around date, single and double quotes around $date, and get the same results. Am I even doing the math part right?