
Originally Posted by
r937
that's nice, salathe, but the dates are wrong

My mistake, I was just going off of the first post:

Originally Posted by
bar338
… only display news articles that were posted in the last month (last 30 days). … how can i use this to determine if the article is more than 30 days old?
To get the days in June (the last full month before today):
PHP Code:
$sqlf = "SELECT foo, bar FROM atable WHERE articleDate >= '%s' AND articleDate < '%s'";
$first = date('Y-m-d', strtotime('first day of last month'));
$last = date('Y-m-d', strtotime('last day of last month'));
$sql = sprintf($sqlf, $first, $last);
// SELECT foo, bar FROM atable WHERE articleDate >= '2009-06-01' AND articleDate < '2009-06-30'
echo $sql;
Bookmarks