Answers.Body: <p>You can use two queries, each for each range, and then merge them like this:</p>
  <pre><code>{% set firstRange = craft.entries({fieldHandle: ['and', '&gt;= '~date1FirstDay, '&lt; '~ date1LastDay]}) %}
  {% set secondRange = craft.entries({fieldHandle: ['and', '&gt;= '~date2FirstDay, '&lt; '~ date2LastDay]}) %}
  
  {% set entries = firstRange |merge(secondRange) %}
  </code></pre>
  <p>This is the way to do it. Also you should query for the ids, and then merge those, and then query by id.</p>
  <p>I hope this will help.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-24T09:55:55.037Z
Answers.LastActivityDate: 2020-12-24T09:55:55.037Z
Answers.UserDisplayName: ZealousWeb
Body: <p>I'm able to successfully query a date field for a date range using this syntax:</p>
  <pre><code>{% set entries = entries.startsOn(['and', '&gt;= '~firstDay, '&lt; '~ lastDay]) %}
  </code></pre>
  <p>What I would like to do however is query that field for multiple date ranges at once with an <code>or</code> operator.</p>
  <p>I can do this with other fields but the date range already using an <code>and</code> operator complicates matters so I can't do the same.</p>
  <pre><code>{% set data = data|merge(['or']) %}
  {% for item in items %}
       {% set data = data|merge(['*'~item~'*']) %}
  {% endfor %}
  </code></pre>
  <p>Any suggestions gratefully received!</p>
  
Tags: <entries>
Title: Query for multiple date ranges on a date field
ThreadText: # Query for multiple date ranges on a date field
  
  (Asked by: username_0 on 2020-11-28)
  
  I'm able to successfully query a date field for a date range using this syntax:
  
  ```
  {% set entries = entries.startsOn(['and', '>= '~firstDay, '< '~ lastDay]) %}
  
  ```
  
  What I would like to do however is query that field for multiple date ranges at once with an `or` operator.
  
  I can do this with other fields but the date range already using an `and` operator complicates matters so I can't do the same.
  
  ```
  {% set data = data|merge(['or']) %}
  {% for item in items %}
       {% set data = data|merge(['*'~item~'*']) %}
  {% endfor %}
  
  ```
  
  Any suggestions gratefully received!
  
  **Tags:** entries
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-12-24. Score: 1
  
  You can use two queries, each for each range, and then merge them like this:
  
  ```
  {% set firstRange = craft.entries({fieldHandle: ['and', '>= '~date1FirstDay, '< '~ date1LastDay]}) %}
  {% set secondRange = craft.entries({fieldHandle: ['and', '>= '~date2FirstDay, '< '~ date2LastDay]}) %}
  
  {% set entries = firstRange |merge(secondRange) %}
  
  ```
  
  This is the way to do it. Also you should query for the ids, and then merge those, and then query by id.
  
  I hope this will help.
  
  
  ---
  
  