<p>100% untested, but something like this should work using Twig's <a href="http://twig.sensiolabs.org/doc/filters/date_modify.html" rel="nofollow">date_modify</a> filter.</p>

<pre><code>{% set startDate = now|date_modify("-6 months") %}

{% set allEntries = craft.entries.section('blog').limit(null).postDate('&gt;= ' ~ startDate) %}

{% for date, entries in allEntries | group("postDate|date('F Y')") %}
    &lt;h2&gt;{{ date }}&lt;/h2&gt;
    &lt;ul&gt;
        {% for entry in entries %}
            &lt;li&gt;{{ entry.getLink() }}&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-08-04T10:14:23.053Z
Instead of `.postDate()` could this also be performed on a custom date/time field (in this case called `startDate`). I'm having trouble getting it to work: `.startDate('>= ' ~ range)`
Ian Young
CC BY-SA 3.0
2016-08-04T11:06:30.870Z
Scratch that, I've managed to get it working now. Thanks Brad! :)
Ian Young
CC BY-SA 3.0
2016-08-04T16:48:10.870Z
No worries! @Ian
Brad Bell
CC BY-SA 3.0
2016-08-03T23:27:42.403Z
2016-08-03T23:27:42.403Z
Brad Bell
<p>From the Creating an Archive Page for Entries article in the Craft docs. How could I limit it so that it grouped by month but limited things to 6 months?:</p>

<pre><code>{% set allEntries = craft.entries.section('blog').limit(null) %}
{% for date, entries in allEntries | group("postDate|date('F Y')") %}
    &lt;h2&gt;{{ date }}&lt;/h2&gt;
    &lt;ul&gt;
        {% for entry in entries %}
            &lt;li&gt;{{ entry.getLink() }}&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
{% endfor %}
</code></pre>

<group><limit><archives>
Date Archives: Last 6 months
# Date Archives: Last 6 months

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

From the Creating an Archive Page for Entries article in the Craft docs. How could I limit it so that it grouped by month but limited things to 6 months?:
{% set allEntries = craft.entries.section('blog').limit(null) %}
{% for date, entries in allEntries | group("postDate|date('F Y')") %}
    {{ date }}
    
        {% for entry in entries %}
            {{ entry.getLink() }}
        {% endfor %}
    
{% endfor %}

**Tags:** group, limit, archives


---

## 1 answers

### Answer by username_1 on 2016-08-03. Score: 1 | Accepted answer

100% untested, but something like this should work using Twig's date_modify filter.
{% set startDate = now|date_modify("-6 months") %}

{% set allEntries = craft.entries.section('blog').limit(null).postDate('>= ' ~ startDate) %}

{% for date, entries in allEntries | group("postDate|date('F Y')") %}
    {{ date }}
    
        {% for entry in entries %}
            {{ entry.getLink() }}
        {% endfor %}
    
{% endfor %}

> **Comments:**
> **username_0**: Instead of `.postDate()` could this also be performed on a custom date/time field (in this case called `startDate`). I'm having trouble getting it to work: `.startDate('>= ' ~ range)`  
> **username_0**: Scratch that, I've managed to get it working now. Thanks Brad! :)  
> **username_1**: No worries! @Ian  

---

