<p>You could try this (not tested):</p>

<pre><code>{% set month = craft.request.getParam('month') %}
{% set year = craft.request.getParam('year')  %}

{% set firstDayOfMonth = now | date_modify('first day of ' ~ month ~ ' ' ~ year ~ ' 00:00:00') %}
{% set lastDayOfMonth = now | date_modify('last day of ' ~ month ~ ' ' ~ year ~ ' 23:59:59') %}

{% set entries = craft.entries.section('yourSection').postDate('and', '&gt;= ' ~ firstDayOfMonth, '&lt;= ' ~ lastDayOfMonth) %}
</code></pre>

CC BY-SA 3.0
2014-10-03T14:35:44.633Z
Thank you very much Paul, your code worked and taught me something new.
user1070143
CC BY-SA 3.0
2014-10-02T14:58:51.100Z
2014-10-02T14:58:51.100Z
Paul
<p>I'm taking the month and year from parameters in the url like this...</p>

<pre><code>{% set month = craft.request.getParam('month') %}
{% set year = craft.request.getParam('year')  %}
</code></pre>

<p>The url would look like this: ?month=September&amp;Year=2014</p>

<p>... and want to return entries from a specific section where the postDate month and year match those parameters.</p>

<p>Be very grateful for any pointers.</p>

<p>Thanks
Lee </p>

<postdate>
How to filter entries by month and year?
# How to filter entries by month and year?

(Asked by: username_0 on 2014-10-02)

I'm taking the month and year from parameters in the url like this...
{% set month = craft.request.getParam('month') %}
{% set year = craft.request.getParam('year')  %}

The url would look like this: ?month=September&Year=2014
... and want to return entries from a specific section where the postDate month and year match those parameters.
Be very grateful for any pointers.
Thanks
Lee

**Tags:** postdate


---

## 1 answers

### Answer by username_1 on 2014-10-02. Score: 8 | Accepted answer

You could try this (not tested):
{% set month = craft.request.getParam('month') %}
{% set year = craft.request.getParam('year')  %}

{% set firstDayOfMonth = now | date_modify('first day of ' ~ month ~ ' ' ~ year ~ ' 00:00:00') %}
{% set lastDayOfMonth = now | date_modify('last day of ' ~ month ~ ' ' ~ year ~ ' 23:59:59') %}

{% set entries = craft.entries.section('yourSection').postDate('and', '>= ' ~ firstDayOfMonth, '<= ' ~ lastDayOfMonth) %}

> **Comments:**
> **username_0**: Thank you very much username_1, your code worked and taught me something new.  

---

