I'm trying to filter entries on the front end by a date range but no matter what I do I end up with no results, despite there being results in the, temporarily hard coded, date range I am using.
{% set page = page ?? 1 %}
{# set search parameter here #}
{% set search = q ?? '' %}
{# stage #}
{% set stage = stage ?? '' %}
{# date #}
{% set start = now|date_modify('-16 week')|atom %}
{% set end = now|date_modify('-1 week')|atom %}
{% set entryQuery = craft.entries
.section('projects')
.limit(limit)
.stage(stage)
.startDate(['and', '>= #{start}', '< #{end}'])
.search(search) %}
{% for entry in entries %}
{% include '_includes/project-listing-card' %}
{% endfor %}
The code above sets some parameters based on the url and defaults. Without the .startDate
line this outputs entries as expected. However once I add in the startDate (a date field) nothing gets output.
How do I output entries that are in the date range?
">= #{start}"
and"< #{end}"
.