<pre><code>{% paginate craft.entries.section('exhibitions').endingDate('&lt; ' ~ now).limit(8) as pastExhibitions %}
  ...
{% endpaginate %}
</code></pre>

<p>This will paginate the entries in section <em>exhibiitions</em> with <em>endingDate</em> <strong>&lt; now</strong>. That <code>~</code> is string concatination operator. The string '&lt; 2014-08-04' queries for entries with endingDate in the past.</p>

CC BY-SA 3.0
2014-08-04T00:46:24.770Z
2014-08-04T00:46:24.770Z
Marion Newlevant
<p>Assuming that I’ve a total number of 10 entries in my <strong>section('exhibitions')</strong> where 8 of them have their <strong>entry.endingDate &lt; now</strong>, I limit the display to 8 entries but the paginate shows a <strong>next button</strong> whereas the next page is empty:</p>

<pre><code>{% paginate craft.entries.section('exhibitions').limit(8) as pastExhibitions %}
    {% for entry in pastExhibitions %}
        {% if entry.endingDate &lt; now %}
            …
        {% endif %}
    {% endfor %}

    {% if paginate.prevUrl %}
        &lt;a href="{{ paginate.prevUrl }}" class="button previous"&gt;&amp;larr; Précédent&lt;/a&gt;
    {% endif %}
    {% if paginate.nextUrl %}
        &lt;a href="{{ paginate.nextUrl }}" class="button next"&gt;Suivant &amp;rarr;&lt;/a&gt;
    {% endif %}

{% endpaginate %}
</code></pre>

<p>How can I add a date filter, in this case <strong>&lt; now</strong>, to the paginate configuration in order to only paginate on entries that are <strong>&lt; now</strong>?</p>

<entries><sections><pagination>
How to use paginate with a date filter?
# How to use paginate with a date filter?

(Asked by: username_0 on 2014-08-03)

Assuming that I’ve a total number of 10 entries in my section('exhibitions') where 8 of them have their entry.endingDate < now, I limit the display to 8 entries but the paginate shows a next button whereas the next page is empty:
{% paginate craft.entries.section('exhibitions').limit(8) as pastExhibitions %}
    {% for entry in pastExhibitions %}
        {% if entry.endingDate < now %}
            …
        {% endif %}
    {% endfor %}

    {% if paginate.prevUrl %}
        ← Précédent
    {% endif %}
    {% if paginate.nextUrl %}
        Suivant →
    {% endif %}

{% endpaginate %}

How can I add a date filter, in this case < now, to the paginate configuration in order to only paginate on entries that are < now?

**Tags:** entries, sections, pagination

---

## 1 answers

### Answer by username_1 on 2014-08-04. Score: 3 | Accepted answer

{% paginate craft.entries.section('exhibitions').endingDate('< ' ~ now).limit(8) as pastExhibitions %}
  ...
{% endpaginate %}

This will paginate the entries in section exhibiitions with endingDate < now. That ~ is string concatination operator. The string '< 2014-08-04' queries for entries with endingDate in the past.


---

