How to compare just the date part of a dateTime field? Ok I want to list event entries based on the start date of those events.

I have a route set up which provides the date in the same format as held in the start date field. But trying to compare this with:

{% for entry in craft.entries.section('events').startDate(date) %}


to pull out only entries for the specified date fails as the date variable only holds the date portion of the startDate field i.e. 2015-10-02 and not the time segment.

So is there some way I can format this call so that the comparison is like with like without the time segment. I have tried a few things with filters but nothing is working.

Cheers
I'm not 100% sure I'm reading your question correctly, but here goes:

I'm assuming you're getting the date as a string as a route param (maybe you shouldn't call it date though, as that is a function in Twig), I'll call that dateTime here:


{% set dayAfter = date(datetime) | date_modify('+1 day') | date('Y-m-d') %}
{% set entries = craft.entries.section('events').startDate(['and', '&gt;= '~datetime, '&lt; '~dayAfter]) %}


What's happening is you get a date, then you add one day to that date, then find all entries that have startDate greater than or equal to the date you're looking for, and less than the day after, thus getting all entries for that particular date.

This might be over engineered though, and there might be a way simpler way to do this...