Orderby Limit # of Days

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 5, 2011   (RSS)

Re: [Illume Magazine] Orderby Limit # of Days

By robin - April 4, 2011

Hi,

Looks like you're close, you just need to change your DATE_SUB. The following where statement should help.
'where' => "date = DATE_SUB(NOW(),INTERVAL 30 DAY) AND approved = 1",
The documentation for MySQL date functions is here:
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Orderby Limit # of Days

Hi Robin,

Thanks for the help. That got rid of the error message, but I am not getting any content.

Re: [Illume Magazine] Orderby Limit # of Days

By robin - April 5, 2011

Hey,

Ah I see, the 'where' I sent you yesterday will only pull records from 30 days ago. We need to make it a range! Here is the 'where' with a range from 30 days ago until now.
'where' => "date BETWEEN DATE_SUB(NOW(),INTERVAL 30 DAY) AND NOW() AND approved = 1 ",

Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Orderby Limit # of Days

Awesome. That worked. Many thanks. You are now a rockstar, along with Ross & Damon!