I’m using the following to get the last 4 events that are after the current date ($filterBy = date(‘Y-m-d’)), but only 3 records are returned. If I increase the limit to 5, then 4 records are returned. Any ideas?
Hey Tina, this is weird, no idea, why this could be happening. Which Kirby version are you using? Any plugins?
Just on a side note, there shouldn’t be a trailing comma and the variable name is superfluous, so sortBy('from', 'asc'), but that’s not the reason why it’s failing.
Ups sorry, I’m using the latest version → 3.9.0 – Brookesia.
I only have one plugin installed, but I’m not using it with a template related to this query → kirby-plugin-custom-add-fields
I’ll try removing the plugin and will look if it makes a difference (I doubt it though).
Update: Removing the plugin made no difference.
PS: for test purposes I created a new template with nothing else in it but the above snippet. I also removed the limit() and sortBy() but it still it renders 1 less record than it should.
Thanks so much Sonja!
Yes, that was the problem, just had to replace “<” with “<=”.
I can’t replace the 00:00:00 for H:i:s though in the filterBy variable, because that would give me the current time, but I want to have all events starting from today.
Yeah, I had that initially but then it was missing an event that was today, but had already past (e.g. the event was at. 3pm and it was now 4pm). So to make sure I get that one, I filter by datetime that starts today at 0 hours.
that worked beautifully and is indeed so much simpler. Needed a slight modification (I don’t want to use the “to()” date as otherwise I’d only get today’s events, but I want those that are today and ones in the future).