<p>I think that you actually want to use 'and' rather than 'or'. 'Or' would return all entries. This is also assuming that you have predefined the 'startDate' and 'endDate' variables.</p>

<pre><code>{% set params = {
    section: 'exhibitions',
    startDate: 'and, &gt;= ' ~ startDate ~ ', &lt;= ' ~ endDate,
    order:'startDate desc'
} %}

{% set startedThisYear = craft.entries(params) %}
</code></pre>

<p>If you haven't already done so, you may need to format 'startDate' and 'endDate' variables first. </p>

<pre><code>startDate: 'and, &gt;= ' ~ startDate|date('Y-m-d') ~ ', &lt;= ' ~ endDate|date('Y-m-d')
</code></pre>

<p>See this answer for <a href="https://craftcms.stackexchange.com/questions/168/how-do-i-show-advanced-date-filters-for-events">another example</a>.</p>

CC BY-SA 3.0
2015-01-28T22:44:22.173Z
2015-01-28T22:50:25.850Z
2017-04-13T12:51:00.253Z
Douglas McDonald
<p>Im trying to do an OR filter for craft.entries and not sure of the syntax</p>

<p>so like this</p>

<pre><code>{% set startedThisYear = craft.entries.find({ section: 'exhibitions', startDate: "&gt;= " ~startDate, startDate: "&lt;= " ~endDate, order:'startDate desc'}) %}
</code></pre>

<p>if i wanted it to be </p>

<p>startDate: ">= " ~startDate or startDate: "&lt;= " ~endDate</p>

<p>??</p>

CC BY-SA 3.0
2015-01-28T22:46:38.657Z
Keith, see my [question here](http://craftcms.stackexchange.com/q/1948/125) for a similar problem that I solved using a workaround collecting entry IDs.
carlcs
CC BY-SA 3.0
2015-01-29T20:18:48.097Z
The 'duplicate' is actually a much more complicated scenario  that might actually confuse people — I'm not sure if it's such a good match. But not a big deal. Problem solved.
Douglas McDonald
CC BY-SA 3.0
2015-01-29T22:40:22.250Z
Yea I agree, I dont think the answer they gave in the "match" is the right answer here.  What I was looking for was the syntax to do 'and' and 'or' conditionals in the craft.entries. queries, where as the other questions solution was to do multiple queries and combine them together.
Keith Mancuso
<elementcriteriamodel>
Or element criteria model filters
# Or element criteria model filters

(Asked by: username_0 on 2015-01-28)

Im trying to do an OR filter for craft.entries and not sure of the syntax
so like this
{% set startedThisYear = craft.entries.find({ section: 'exhibitions', startDate: ">= " ~startDate, startDate: "<= " ~endDate, order:'startDate desc'}) %}

if i wanted it to be 
startDate: ">= " ~startDate or startDate: "<= " ~endDate
??

**Tags:** elementcriteriamodel
> **Comments:**
> **username_1**: Keith, see my [question here](http://craftcms.stackexchange.com/q/1948/125) for a similar problem that I solved using a workaround collecting entry IDs.  
> **username_2**: The 'duplicate' is actually a much more complicated scenario  that might actually confuse people — I'm not sure if it's such a good match. But not a big deal. Problem solved.  
> **username_0**: Yea I agree, I dont think the answer they gave in the "match" is the right answer here.  What I was looking for was the syntax to do 'and' and 'or' conditionals in the craft.entries. queries, where as the other questions solution was to do multiple queries and combine them together.  

---

## 1 answers

### Answer by username_2 on 2015-01-28. Score: 7 | Accepted answer

I think that you actually want to use 'and' rather than 'or'. 'Or' would return all entries. This is also assuming that you have predefined the 'startDate' and 'endDate' variables.
{% set params = {
    section: 'exhibitions',
    startDate: 'and, >= ' ~ startDate ~ ', <= ' ~ endDate,
    order:'startDate desc'
} %}

{% set startedThisYear = craft.entries(params) %}

If you haven't already done so, you may need to format 'startDate' and 'endDate' variables first. 
startDate: 'and, >= ' ~ startDate|date('Y-m-d') ~ ', <= ' ~ endDate|date('Y-m-d')

See this answer for another example.


---

