So I'm trying to build a query based on events and their start and end dates. Once a user selects a year, I want to display all events that took place in that year, but also display events that might have spanned across multiple years and include that selected year. For example, if a user selects 2012. I should display all events starting in 2012, but also events that might have lasted from say 2010-2013.
What I'd like to do is query all event entries and return only events whose startDate is less than or equal to the select year AND whose end date is greater than or equal to the selected year:
{% set startDateParam = '<=' ~ yearParam ~ '-01-01' %}
{% set endDateParam = '>=' ~ yearParam ~ '-01-01' %}
{% set pastEntries = craft.entries({
startDate: startDateParam,
endDate: endDateParam
}).section('events').order('endDate desc') %}
However, this doesn't seem to work. What is the correct way to query for entries that satisfy both the startDate AND endDate?
Any and all help is greatly appreciated. Thanks.