I think you're missing INTERVAL
at the front of 1 week
:
SELECT *
FROM emails
WHERE (DATE(date) = date_sub(date('2011-09-17 00:00:00'), INTERVAL 1 week));
Here is a query that I ran that does work for the DATE_SUB()
part:
SELECT *
FROM wp_posts
WHERE post_modified > DATE_SUB(CURDATE(), INTERVAL 4 WEEK);
You can use a negative value to go do a "N weeks before given date" query so something like this would work:
SELECT *
FROM wp_posts
WHERE post_modified > DATE_SUB(CURDATE(), INTERVAL -1 WEEK);
Or:
SELECT *
FROM emails
WHERE (DATE(date) = date_sub(date('2011-09-17 00:00:00'), INTERVAL -1 week))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…