Answers.Body: <p>Instead of grabbing <em>all</em> entries in the <code>eventsEntry</code> section, then filtering by the current date/time, you could do the filtering on the database side first, so you're returning only the entries you're interested in.</p>
  
  <p>Something like this:</p>
  
  <pre><code>{% set pastEvents = craft.entries.section('eventsEntry').eventdate('&lt;= ' ~ now|atom) %}
  
  {% for date, entries in pastEvents | group("pastEvents.eventdate|date('Y')") %}
      &lt;h4&gt;{{ date }}&lt;/h4&gt;
  
      &lt;ul&gt;
          {% for event in pastEvents.all() %}
              &lt;li&gt;
                  {{ event.eventdate|date('d/m/y') }}
                  {{ event.title }}
              &lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T18:43:22.277Z
Answers.LastActivityDate: 2018-06-13T18:43:22.277Z
Answers.UserDisplayName: Brad Bell
Body: <p>I've hacked this together to create an event archive listing, and although it works, I'm wondering if it's 'correct' or could be done more succinctly?</p>
  
  <pre><code>{% set pastEvents = craft.entries.section('eventsEntry').orderBy('eventDate') %}
     {% for date, entries in pastEvents | group("pastEvents.eventDate|date('Y')") %}
          &lt;h4&gt;{{ date }}&lt;/h4&gt;
              &lt;ul&gt;
                  {% for event in pastEvents.all() if event.eventDate &lt;= now %}
                  &lt;li&gt;
                      {{ event.eventDate|date('d/m/y') }}
                      {{ event.title }}
                  &lt;/li&gt;                   
                  {% endfor %} 
              &lt;/ul&gt;   
     {% endfor %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-12T18:45:13.783Z
Comments.Text: Looks good to me. For the most part if it works for you it's correct.
Comments.UserDisplayName: Simon Kuran
Tags: <templating>
Title: Template for event archive
ThreadText: # Template for event archive
  
  (Asked by: username_0 on 2018-06-12)
  
  I've hacked this together to create an event archive listing, and although it works, I'm wondering if it's 'correct' or could be done more succinctly?
  
  ```
  {% set pastEvents = craft.entries.section('eventsEntry').orderBy('eventDate') %}
     {% for date, entries in pastEvents | group("pastEvents.eventDate|date('Y')") %}
          <h4>{{ date }}</h4>
              <ul>
                  {% for event in pastEvents.all() if event.eventDate <= now %}
                  <li>
                      {{ event.eventDate|date('d/m/y') }}
                      {{ event.title }}
                  </li>                   
                  {% endfor %} 
              </ul>   
     {% endfor %}
  
  ```
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: Looks good to me. For the most part if it works for you it's correct.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-06-13. Score: 1 | Accepted answer
  
  Instead of grabbing *all* entries in the `eventsEntry` section, then filtering by the current date/time, you could do the filtering on the database side first, so you're returning only the entries you're interested in.
  
  Something like this:
  
  ```
  {% set pastEvents = craft.entries.section('eventsEntry').eventdate('<= ' ~ now|atom) %}
  
  {% for date, entries in pastEvents | group("pastEvents.eventdate|date('Y')") %}
      <h4>{{ date }}</h4>
  
      <ul>
          {% for event in pastEvents.all() %}
              <li>
                  {{ event.eventdate|date('d/m/y') }}
                  {{ event.title }}
              </li>
          {% endfor %}
      </ul>
  {% endfor %}
  
  ```
  
  
  ---
  
  