I am trying to select records from a MySQL table that are between 1 and 2 weeks old The table has a date column. There is a date that is 10 days old but the query is ignoring it. Can you help please? Here is the query I am using:
$week2 = mysql_query("SELECT * FROM apps WHERE (user = '"
.mysql_real_escape_string($_POST['username']) . "') and date BETWEEN ( DATE_SUB( NOW(),
INTERVAL 2 WEEK), DATE_SUB( NOW(), INTERVAL 1 WEEK )");
If I make the date less than a week old, I can select the record no problem with:
$week1 = mysql_query("SELECT * FROM apps WHERE (user = '" .
mysql_real_escape_string($_POST['username']) . "') and date > NOW() - INTERVAL 1 WEEK
ORDER BY id DESC limit 1");