Answers.Body: <p>You could fetch your entries then split them in three arrays which would give you the ability to then add headings manually and display as you need to.</p>
  
  <pre class="lang-twig prettyprint-override"><code>{# Define today and three arrays to hold your grouped entries #}
  {% set today = now|atom %}
  {% set futureBids = [] %}
  {% set currentBids = [] %}
  {% set pastBids = [] %}
  
  {# Fetch your entries #}
  {% set entries = craft.entries().section('bids').all() %}
  
  {# Populate your groups #}
  {% for entry in entries %}
      {% set starts = entry.biddingStartDate | atom %}
      {% set ends = entry.biddingEndDate | atom %}
  
      {# future #}
      {% if starts &gt; today %}
          {% set futureBids = futureBids | merge([entry]) %}
  
      {# current #}
      {% elseif starts &lt;= today and ends &gt; today %}
          {% set currentBids = currentBids | merge([entry]) %}
  
      {# past #}
      {% elseif ends &lt; today %}
          {% set pastBids = pastBids | merge([entry]) %}
      {% endif %}
  {% endfor %}
  
  {# Display as you need... #}
  
  &lt;h2&gt;Current Bids&lt;/h2&gt;
  &lt;hr&gt;
  {% for entry in currentBids %}
      {{ entry.title }}&lt;br&gt;
  {% endfor %}
  
  &lt;h2&gt;Future Bids&lt;/h2&gt;
  &lt;hr&gt;
  {% for entry in futureBids %}
      {{ entry.title }}&lt;br&gt;
  {% endfor %}
  
  
  &lt;h2&gt;Past Bids&lt;/h2&gt;
  &lt;hr&gt;
  {% for entry in pastBids %}
      {{ entry.title }}&lt;br&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-23T12:59:14.197Z
Answers.LastActivityDate: 2020-03-23T12:59:14.197Z
Answers.UserDisplayName: Oli
Body: <p>I'm looking to group entries based on a condition between two custom date fields and the current date. I'm not even sure this is possible, but this is how it would appear visually:</p>
  
  <p><strong>Happening Now</strong></p>
  
  <p>Entry 1</p>
  
  <p>Entry 2</p>
  
  <p><strong>Happening in the future</strong></p>
  
  <p>Entry 3</p>
  
  <p>Entry 4</p>
  
  <p><strong>Happened in the past</strong></p>
  
  <p>Entry 5</p>
  
  <p>Entry 6</p>
  
  <p>These entries all have two custom date fields, <code>biddingStartDate</code> and <code>biddingEndDate</code>. If the current date is between <code>biddingStartDate</code> and <code>biddingEndDate</code>, it should go under "Happening Now"; if the current date is before <code>biddingStartDate</code>, it should go under "Happening in the future"; and if the current date is after <code>biddingEndDate</code>, it should go under "Happened in the past".</p>
  
  <p>The other large question here would be: how would the headings even be created since they're dynamic and not stored in the database?</p>
  
Tags: <datetime><filter><group>
Title: Grouping entries by a custom date conditional
ThreadText: # Grouping entries by a custom date conditional
  
  (Asked by: username_0 on 2020-03-20)
  
  I'm looking to group entries based on a condition between two custom date fields and the current date. I'm not even sure this is possible, but this is how it would appear visually:
  
  **Happening Now**
  
  Entry 1
  
  Entry 2
  
  **Happening in the future**
  
  Entry 3
  
  Entry 4
  
  **Happened in the past**
  
  Entry 5
  
  Entry 6
  
  These entries all have two custom date fields, `biddingStartDate` and `biddingEndDate`. If the current date is between `biddingStartDate` and `biddingEndDate`, it should go under "Happening Now"; if the current date is before `biddingStartDate`, it should go under "Happening in the future"; and if the current date is after `biddingEndDate`, it should go under "Happened in the past".
  
  The other large question here would be: how would the headings even be created since they're dynamic and not stored in the database?
  
  **Tags:** datetime, filter, group
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-03-23. Score: 2 | Accepted answer
  
  You could fetch your entries then split them in three arrays which would give you the ability to then add headings manually and display as you need to.
  
  ```twig
  {# Define today and three arrays to hold your grouped entries #}
  {% set today = now|atom %}
  {% set futureBids = [] %}
  {% set currentBids = [] %}
  {% set pastBids = [] %}
  
  {# Fetch your entries #}
  {% set entries = craft.entries().section('bids').all() %}
  
  {# Populate your groups #}
  {% for entry in entries %}
      {% set starts = entry.biddingStartDate | atom %}
      {% set ends = entry.biddingEndDate | atom %}
  
      {# future #}
      {% if starts > today %}
          {% set futureBids = futureBids | merge([entry]) %}
  
      {# current #}
      {% elseif starts <= today and ends > today %}
          {% set currentBids = currentBids | merge([entry]) %}
  
      {# past #}
      {% elseif ends < today %}
          {% set pastBids = pastBids | merge([entry]) %}
      {% endif %}
  {% endfor %}
  
  {# Display as you need... #}
  
  <h2>Current Bids</h2>
  <hr>
  {% for entry in currentBids %}
      {{ entry.title }}<br>
  {% endfor %}
  
  <h2>Future Bids</h2>
  <hr>
  {% for entry in futureBids %}
      {{ entry.title }}<br>
  {% endfor %}
  
  <h2>Past Bids</h2>
  <hr>
  {% for entry in pastBids %}
      {{ entry.title }}<br>
  {% endfor %}
  
  ```
  
  
  ---
  
  