Convert string to date format that can be used in a craft.entries tag I've got a date string from the url in this format: &quot;2021-06-01&quot; (year-month-day) and I want to find entries that have a date in the year and month from that string. The date is a date field in Craft.
{% set entries = entries.startsOn(craft.app.request.getParam('departure')|date(&quot;Y-m&quot;)) %}

That does not work!
Any ideas gratefully received!
You could do this:
{# Your date 2020-11 in atom format e.g 2020-11-01T00:00:00+01:00 #}
{% set departureDate = craft.app.request.getParam('departure') | date(&quot;Y-m&quot;) | atom %}

{# Your date + 1 month in atom format e.g 2020-12-01T00:00:00+01:00 #}
{% set untilDate = departureDate | date_modify('+1 month') | atom %}

{# Query between those 2 dates #}
{% set query = query.startsOn(['and','&gt;=' ~ departureDate, '&lt;' ~  untilDate ]) %}

Note that on the November the 25th for example, you'd only be querying 5 days of the month