Creating a date filtered archive template I'm trying to create an archive list template that lists entries from a News or Blog Channel based on year/month/day combinations.

However, I get no entries and can't see where I'm going wrong...I'm running the latest build of Craft.

{% if year is not defined %}
    {% redirect "news/archives/"~now.year %}
{% endif %}

{% set year  = craft.request.segment(3)  %}
{% set month = craft.request.segment(4) %}
{% set day = craft.request.segment(5) %}

Year: {{ year }}&lt;br&gt;
Month: {{ month }}&lt;br&gt;
Day: {{ day }}&lt;br&gt;&lt;br&gt;

{% if (year | length) and (month | length) and (day | length) %}
    {% set entryDate = year ~ '-' ~ month ~ '-' ~ day %}
{% elseif (year | length) and (month | length) %}
    {% set entryDate = year ~ '-' ~ month %}
{% elseif (year | length) %}
    {% set entryDate = year %}
{% endif %}

Entry Date: {{ entryDate }}&lt;br&gt;&lt;br&gt;

{% set entries = craft.entries.find({section: "news", postDate: entryDate}) %}

{% if entries | length %}
    Entries found.
{% else %}
    No entries found.
{% endif %}
I've used this method for sorting by year and month (it could be expanded to support days).

On the news/index.html template:

{% if month is defined %} {# show an archive of a month #}

    {% set sortDate = year ~ '-' ~ month %}

    Entry Date: {{ sortDate }}

    {% if month != 12 %}
        {% set nextmonth = month+1 %}
        {% set nextyear = year %}
    {% else %}
        {% set nextmonth = 01 %}
        {% set nextyear = year+1 %}
    {% endif %}

    {% set entriesToShow = craft.entries.section('news').limit(null).after(year ~ '-' ~ month).before(nextyear ~ '-' ~ nextmonth) %}

{% elseif year is defined %} {# show an archive of a year #}

    Entry Date: {{ year }}

    {% set entriesToShow = craft.entries.section('news').limit(null).after(year).before(year+1) %}

{% else %} {# assume overview page #}

    {% set entriesToShow = craft.entries.section('news') %}

{% endif %}


Any entries can then be displayed by one loop.

{% for entry in entriesToShow %}


Since this is made to be in on the section's index template you don't need a separate archive template. Just setup a few routes in the CP to send the archive tokens back to the index template.

Set all the token combinations you need like:

news/archive/(month)/(year)


To route to:

news/index.html