2

Why does this work fine

{% paginate craft.entries().limit(7).section('events').eventStartDate('>= ' ~ 2014 ~ '-' ~ 09) as entriesOnPage %}

But this does not

{% paginate craft.entries().limit(7).section('events').eventStartDate('>= ' ~ 2014 ~ '-' ~ 09) as entriesOnPage %}

I get this http://d.pr/i/NRvg

I also get errors when simply using '<' so it seems to require only either a less than or equal to or a greater than or equal to operator.

Can someone point to some kind of documentation for what is allowed within the custom field filter -------------> this part ('<= ' ~ 2014 ~ '-' ~ 09)

Matt Green
  • 428
  • 4
  • 6
  • 1
    It's entirely possible I'm going blind, but what's the difference between those two queries? They look identical to me. – Brad Bell Aug 12 '14 at 17:24

2 Answers2

1

You shouldn't need to use string concatenation here:

.eventStartDate('>= ' ~ 2014 ~ '-' ~ 09)

If you're hard coding the year and month, just use:

.eventStartDate('>= 2014-09-01')
Brad Bell
  • 67,440
  • 6
  • 73
  • 143
1

Ahhhhh. I was because before I changed that I was pulling from a segment which was a string. I figured it out though. Ended up with this which works out...

{% set year = craft.request.segment(2) %}
{% set month = craft.request.segment(3) %}
{% set firstDayOfMonth = year ~ "-" ~ month ~ "-01" %}
{% set daysInThisMonth = firstDayOfMonth|date('t') %}
{% set lastDayOfMonth = year ~ "-" ~ month ~ "-" ~ daysInThisMonth %}

{% paginate craft.entries()
    .limit(7)
    .section('events')
    .eventStartDate('>= ' ~ firstDayOfMonth | date("U"))
    .eventEndDate('<= ' ~ lastDayOfMonth | date("U"))
as entriesOnPage %}
Matt Green
  • 428
  • 4
  • 6