Return entries with startDate or endDate within a calendar year I have two date fields in my entry and I want to return those entries with either a start date OR and end date within a calendar year.

I can get those with a startDate within the calendar year using:

{% set nextyear = year +1 %}
{% set yearbegins = '1 January ' ~ year %}
{% set yearends = '1 January' ~ nextyear %}
{% set unixbegins = yearbegins | date("U") %}
{% set unixends = yearends | date("U") %}

{% set entries = craft.entries.section('events').limit(null).startDate('and', '&gt;= ' ~ unixbegins, '&lt; ' ~ unixends) %}


How to I then run a test on endDate to further filter them down?&nbsp;
You could do two queries to get the Ids of the desired entries, merge the Ids and then query the entries with these Ids:

{# Get Ids of desired entries #}
{% set startDateIds = craft.entries.startDate('and', '&gt;= ' ~ unixbegins, '&lt; ' ~ unixends).ids() %}
{% set endDateIds = craft.entries.endDate('and', '&gt;= ' ~ unixbegins, '&lt; ' ~ unixends).ids() %}

{# Merge queried Ids #}
{% set filteredIds = startDateIds|merge(endDateIds) %}

{# Get entries with Id paramenter #}
{% set filteredEntries = craft.entries.id(filteredIds) %}


.

Another idea is to query all potential entries, loop those and filter within the loop. This is probably the way to go if you need to combine your conditionals with other logic then the and operator:

{# Get all potential entries #}
{% set allEntries = craft.entries.section('events').limit(null).find() %}

{# Define array before loop #}
{% set filteredEntries = {} %}

{# Loop all entries #}
{% for key, entry in allEntries %}

    {# Set conditionals to filter for desired entries #}
    {% if ( entry.startDate &gt;= unixbegins and entry.startDate &lt; unixends ) and ( entry.endDate &gt;= unixbegins and entry.endDate &lt; unixends ) %}

        {# Merge entries #}
        {% set filteredEntries = filteredEntries|merge({ (key): entry }) %}
    {% endif %}

{% endfor %}