How can I get entries where a date is within a dynamic date range? {% set params = {
      section : 'events',
      order : 'eventStartDate asc',
      eventStartDate : '&gt;=' ~ now,
      limit : row.itemsPerPage.value
} %}


I am trying to pull a set of event entries for a basic event calendar and I'm trying to figure out the syntax for the eventStartDate parameter to have it pull starting with the current date and ending with a value of the current date + 1 month, 3 months, or 6 months depending on the value set in another field named eventDateRange. I need help with how to write that as a command like the one listed above.
Ok, so in the end you’d want your “startDate” custom field parameter to be a string in this format:

'and, &gt;= 2017-08-04T05:00:00+08:00, &lt; 2017-08-11T04:59:59+08:00'


I’m outputting a format for the dates that includes the time and timezone, so that we are able to define when exactly events are being refreshed. To do that I’m using the date filter (otherwise Twig outputs dates in Y-m-d format).

Here’s how you compose the final string including the value from the Global Set, that I am simply concatenating to a string that I pass into the date_modify filter.

{% set var = myGlobalSet.myNumbersField %}

{% set rangeStart = now|date_modify('5:00')|date('c') %}
{% set rangeEnd = now|date_modify('5:00 +' ~ var ~ ' weeks')|date('c') %}

{% set startDateParam = 'and, &gt;=' ~ rangeStart ~ ', &lt;' ~ rangeEnd %}