Link to home
Start Free TrialLog in
Avatar of phillystyle123
phillystyle123Flag for United States of America

asked on

Joomla - trying to post articles less than 6 months old

I'm using a module called "Recent News" which scrolls articles from a given category. I need to set the sql so it's only outputting articles that are 6 months old or newer.

here's the sql:

 "SELECT c.id AS id, c.title AS title, c.catid as catid, c.sectionid as sectionid, c.alias as title_alias

  FROM #__content AS c

		INNER JOIN #__categories AS cat

		ON(c.catid = cat.id) AND (cat.access <= $gid)

		INNER JOIN #__sections AS sec

		ON(c.sectionid = sec.id)

  WHERE c.state = '1'

   	AND ( c.publish_up = " . $database->Quote($nullDate) . " OR c.publish_up <= " . $database->Quote($now) . " )

    AND ( c.publish_down = " . $database->Quote($nullDate) . " OR c.publish_down >= " . $database->Quote($now) . " )

	AND cat.published = '1'

	AND sec.published = '1' ";

Open in new window

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

You can get the timestamp value of 6 months ago from something like this:

Now - 6 months

Example:
http://www.laprbass.com/RAY_strtotime.php?s=now+-+6+months

Not sure what column of your DB table would need to be in the WHERE clause, but you probably know that part ;-)
Avatar of phillystyle123

ASKER

thanks ray - how would that work in this:

AND ( c.created = " .$database->Quote( date('Y-m-d', strtotime('-90 days')) ). "
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
so the actual strtotime is

today -  6 months
Yes.  Either "Today" or "Now" should work.  "Now" includes the time of day, and "Today" just includes the date (time is midnight).
perfecto ray - thanks!
Glad to help.  Thanks for the points and thanks for using EE! ~Ray