Answers.Body: <p>Perhaps you could use the Preparse Field plugin, so that you only need to deal with one field. That would make the query easier.
  <a href="https://plugins.craftcms.com/preparse-field" rel="nofollow noreferrer">https://plugins.craftcms.com/preparse-field</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-18T19:26:08.550Z
Answers.Text: Thanx, didn't know that plugin, searched for something like that but couldn't find anything. This solved my problem!
Answers.UserDisplayName: Maarten Heideman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-18T20:52:30.133Z
Answers.Text: Happy to hear it worked out!
Answers.UserDisplayName: KSP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-17T23:01:09.967Z
Answers.LastActivityDate: 2020-06-17T23:01:09.967Z
Answers.UserDisplayName: KSP
Body: <p>I'll import (event) entries with feedme in craftcms 2 from an API who I'll can't change. The api gives the startdate off the events in a dateTime object. The allDay events have a date without time. Because the api also names those date elements different (start/dateTime, start/date) I'll have to import the data separate in to two fields for start and for end.</p>
  <p>The question is how I'll get all those events (entries) together ordered by date? From the current date to the currentdate plus 6 months. The entries with the allDay date have an empty field for startDate and endDate and visa versa.</p>
  <p>This is what I'll have but that didn't work.</p>
  <pre><code>  'api/calendar' =&gt; function() {
  
              // Fetch global set 'agenda'
  
              return [
                  'elementType' =&gt; 'Entry',
                  'criteria' =&gt; [
                      'limit' =&gt; 0,
                      'startDate' =&gt; ['and', '&gt;=' . date('U') . &quot;&quot;],
                      'endDate' =&gt; ['and', '&lt;=' . date('U', strtotime(&quot;+6 months&quot;)) . &quot;&quot;],
  
                      'startDateAllDay' =&gt; ['and', '&gt;=' . date('U') . &quot;&quot;],
                      'endDateAllDay' =&gt; ['and', '&lt;=' . date('U', strtotime(&quot;+6 months&quot;)) . &quot;&quot;],
                      'order'     =&gt; 'startDatum asc'
                  ],
  </code></pre>
  
Tags: <plugin-elementapi><datetime><craft2><plugin-feedme><import>
Title: How get entries between mutiple dates, ordered by date?
ThreadText: # How get entries between mutiple dates, ordered by date?
  
  (Asked by: username_0 on 2020-06-17)
  
  I'll import (event) entries with feedme in craftcms 2 from an API who I'll can't change. The api gives the startdate off the events in a dateTime object. The allDay events have a date without time. Because the api also names those date elements different (start/dateTime, start/date) I'll have to import the data separate in to two fields for start and for end.
  
  The question is how I'll get all those events (entries) together ordered by date? From the current date to the currentdate plus 6 months. The entries with the allDay date have an empty field for startDate and endDate and visa versa.
  
  This is what I'll have but that didn't work.
  
  ```
    'api/calendar' => function() {
  
              // Fetch global set 'agenda'
  
              return [
                  'elementType' => 'Entry',
                  'criteria' => [
                      'limit' => 0,
                      'startDate' => ['and', '>=' . date('U') . ""],
                      'endDate' => ['and', '<=' . date('U', strtotime("+6 months")) . ""],
  
                      'startDateAllDay' => ['and', '>=' . date('U') . ""],
                      'endDateAllDay' => ['and', '<=' . date('U', strtotime("+6 months")) . ""],
                      'order'     => 'startDatum asc'
                  ],
  
  ```
  
  **Tags:** plugin-elementapi, datetime, craft2, plugin-feedme, import
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-06-17. Score: 1 | Accepted answer
  
  Perhaps you could use the Preparse Field plugin, so that you only need to deal with one field. That would make the query easier.
  <https://plugins.craftcms.com/preparse-field>
  
  > **Comments:**
  > **username_0**: Thanx, didn't know that plugin, searched for something like that but couldn't find anything. This solved my problem!  
  > **username_1**: Happy to hear it worked out!  
  
  ---
  
  