Display by month

3 posts by 3 authors in: Forums > CMS Builder
Last Post: July 28, 2017   (RSS)

By KennyH - July 22, 2017

I am trying to display 10 records where the date matches the current month. So say I have records with dates throughout the year. I want to show 10 records starting with those in this current month. If there are only 8 records for the current month, then show me two more from the next month.

I have figured out the sorting by using 

'orderBy'     => 'Month(domain_registered)',
'limit'       => '10',

but that always shows the same first 10 entries.  I want it to show 10 entries starting with the current month

Ideas?

Kenny

By kitsguru - July 25, 2017

Could you supply your complete getRecords call? I suspect your where clause is the issue.

Jeff Shields

By Dave - July 28, 2017

Hi Kenny, 

Sorry for the delay.  Every I still Google these things as it's faster.  Here's my process: 

Try this:

'where' => " domain_registered >= DATE_FORMAT(NOW() ,'%Y-%m-01') ",

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com