Display by month
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
Could you supply your complete getRecords call? I suspect your where clause is the issue.
Sorry for the delay. Every I still Google these things as it's faster. Here's my process:
- Google: mysql get date for start of month - https://www.google.ca/search?q=mysql+get+date+for+start+of+month
- Scan some stackoverflow posts for some easy code: DATE_FORMAT(NOW() ,'%Y-%m-01')
- Try it out in MySQL Console: https://www.interactivetools.com/add-ons/developer-console/
- Come up with where query: domain_registered >= DATE_FORMAT(NOW() ,'%Y-%m-01')
'where' => " domain_registered >= DATE_FORMAT(NOW() ,'%Y-%m-01') ",
Hope that helps!