Answers.Body: <p>This should get it sorted.  There were 2 issues with yours.  First is you were using the wrong 'and' syntax in the <code>craft.entries</code> call and second you need to use the <code>Y-m-d</code> pattern so MySQL understands to convert it a proper DateTime field instead of the <code>m/d/Y</code> format you had.</p>
  
  <pre><code>{% set currMonth = now|date('m') %}
  {% set currMonthFirst = now|date('Y') ~ '-' ~ currMonth ~ '-1'  %}
  {% set nextMonthFirst = currMonthFirst|date_modify('+1 month') %}
  
  &lt;p&gt;{{ currMonthFirst|date('Y-m-d') }} - {{ nextMonthFirst|date('Y-m-d') }}&lt;/p&gt;
  
  {% set events = craft.entries.section('events').event_startDateTime('and', '&gt;= ' ~ currMonthFirst|date('Y-m-d'), '&lt; ' ~ nextMonthFirst|date('Y-m-d')) %}
  
  {% for event in events %}
      &lt;h1&gt;{{event.title}}&lt;/h1&gt;
  {% endfor %}
  </code></pre>
  
  <p>Completely untested, but try using:</p>
  
  <pre><code>{% set events = craft.entries.section('events').event_startDateTime('and', '&gt;= ' ~ currMonthFirst|date('m/d/Y'), '&lt; ' ~ nextMonthFirst|date('m/d/Y')) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-27T21:13:46.733Z
Answers.Text: That doesn't fix the error, sadly.
  
  I've also tried casting both date variables into strings, but that doesn't fix the problem.  Nor does trying the loop with just 'nextMonthFirst', which is a date variable to begin with ('currMonthFirst' ends up as a string).
Answers.UserDisplayName: Jacob Russell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-27T21:14:43.077Z
Answers.Text: Can you enable devMode and post the full stack trace to the error?
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-27T23:03:06.207Z
Answers.Text: Updated the answer.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-28T18:09:23.120Z
Answers.Text: You are a wonderful human being.
Answers.UserDisplayName: Jacob Russell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-27T03:33:57.877Z
Answers.LastActivityDate: 2015-02-27T23:02:59.687Z
Answers.LastEditDate: 2015-02-27T23:02:59.687Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm trying to pull entries from an events channel where a date field falls in the current month.  Through google and other SE posts I've gotten to the following code:</p>
  
  <pre><code>{% set currMonth = now|date('m') %}
  {% set currMonthFirst = currMonth ~ '/1/' ~ now|date('Y') %}
  {% set nextMonthFirst = currMonthFirst|date_modify('+1 month') %}
  &lt;p&gt;{{ currMonthFirst|date('m/d/Y') }} - {{ nextMonthFirst|date('m/d/Y') }}&lt;/p&gt;
  
  {% set events = craft.entries.section('events').event_startDateTime('&gt;= ' ~ currMonthFirst|date('m/d/Y') ~ ', &lt;' ~ nextMonthFirst|date('m/d/Y')) %}
  
  {% for event in events %}
      &lt;h1&gt;{{event.title}}&lt;/h1&gt;
  
  {% endfor %}
  </code></pre>
  
  <p>currMonthFirst and nextMonthFirst both output the dates I'd expect, but when I use the set &amp; for loop I get the following error - Fatal error: Call to a member function getTimestamp() on a non-object.  Any idea what I'm doing wrong here or how to make what I'm trying to do work?</p>
  
Tags: <datetime><events>
Title: Entries where field = current month?
ThreadText: # Entries where field = current month?
  
  (Asked by: username_0 on 2015-02-27)
  
  I'm trying to pull entries from an events channel where a date field falls in the current month. Through google and other SE posts I've gotten to the following code:
  
  ```
  {% set currMonth = now|date('m') %}
  {% set currMonthFirst = currMonth ~ '/1/' ~ now|date('Y') %}
  {% set nextMonthFirst = currMonthFirst|date_modify('+1 month') %}
  <p>{{ currMonthFirst|date('m/d/Y') }} - {{ nextMonthFirst|date('m/d/Y') }}</p>
  
  {% set events = craft.entries.section('events').event_startDateTime('>= ' ~ currMonthFirst|date('m/d/Y') ~ ', <' ~ nextMonthFirst|date('m/d/Y')) %}
  
  {% for event in events %}
      <h1>{{event.title}}</h1>
  
  {% endfor %}
  
  ```
  
  currMonthFirst and nextMonthFirst both output the dates I'd expect, but when I use the set & for loop I get the following error - Fatal error: Call to a member function getTimestamp() on a non-object. Any idea what I'm doing wrong here or how to make what I'm trying to do work?
  
  **Tags:** datetime, events
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-02-27. Score: 4 | Accepted answer
  
  This should get it sorted. There were 2 issues with yours. First is you were using the wrong 'and' syntax in the `craft.entries` call and second you need to use the `Y-m-d` pattern so MySQL understands to convert it a proper DateTime field instead of the `m/d/Y` format you had.
  
  ```
  {% set currMonth = now|date('m') %}
  {% set currMonthFirst = now|date('Y') ~ '-' ~ currMonth ~ '-1'  %}
  {% set nextMonthFirst = currMonthFirst|date_modify('+1 month') %}
  
  <p>{{ currMonthFirst|date('Y-m-d') }} - {{ nextMonthFirst|date('Y-m-d') }}</p>
  
  {% set events = craft.entries.section('events').event_startDateTime('and', '>= ' ~ currMonthFirst|date('Y-m-d'), '< ' ~ nextMonthFirst|date('Y-m-d')) %}
  
  {% for event in events %}
      <h1>{{event.title}}</h1>
  {% endfor %}
  
  ```
  
  Completely untested, but try using:
  
  ```
  {% set events = craft.entries.section('events').event_startDateTime('and', '>= ' ~ currMonthFirst|date('m/d/Y'), '< ' ~ nextMonthFirst|date('m/d/Y')) %}
  
  ```
  
  > **Comments:**
  > **username_0**: That doesn't fix the error, sadly.  I've also tried casting both date variables into strings, but that doesn't fix the problem.  Nor does trying the loop with just 'nextMonthFirst', which is a date variable to begin with ('currMonthFirst' ends up as a string).  
  > **username_1**: Can you enable devMode and post the full stack trace to the error?  
  > **username_1**: Updated the answer.  
  > **username_0**: You are a wonderful human being.  
  
  ---
  
  