Answers.Body: <p>This should work below. Rather than querying all entries and looping through, just select the entries you need (ie. <code>now</code>) and limit them. </p>
  
  <pre><code>{% set upcomingEvents = craft.entries.section('events').eventDate('&gt;= '~now).limit(2) %}
  {% for event in upcomingEvents %}
      &lt;!-- markup here --&gt;
  {% endfor %} 
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-05T19:23:02.917Z
Answers.Text: Hi, thanks. Just tried this but its giving me a "Fatal error: Call to a member function getTimestamp() on boolean" with a large call stack table.
Answers.UserDisplayName: dace
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-05T19:26:16.070Z
Answers.Text: Should also clarify that the date I need to make sure it's displaying after today is the eventDate of the entry (a custom field I set) and not the published or posted date.
Answers.UserDisplayName: dace
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-05T19:53:48.670Z
Answers.Text: I guess `.after('>= '~now)` should be `.eventDate('>= '~now)`, otherwise this looks solid.
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-05T21:29:12.763Z
Answers.Text: Yes!! Thanks! Using ".eventDate(...)" worked for me. Appreciate the help!!
Answers.UserDisplayName: dace
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-05T19:04:01.657Z
Answers.LastActivityDate: 2016-08-05T20:11:35.850Z
Answers.LastEditDate: 2016-08-05T20:11:35.850Z
Answers.UserDisplayName: Siebird
Body: <p>Trying to pull in a limit of 2 events that are upcoming (so the event's eventDate should be newer than today). I currently have this: </p>
  
  <pre><code>{% set entries = craft.entries.section('events').order('eventDate asc') %}
  {% set today = now|date('Y-m-d') %} 
  
  {% for event in entries %}
    {% if today &lt;= event.eventDate %}
      &lt;!-- markup here --&gt;
    {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>However, this returns all events that are upcoming. I would like to only limit it to 2. The problem when I put the .limit(2) on my for loop is that it chooses the first two (and those happen to be older events). Do I need to do another loop within the if statement and add .limit(2) to that or is there a better way?</p>
  
  <p>Thanks!</p>
  
Tags: <entry>
Title: Possible to filter an entry based on property?
ThreadText: # Possible to filter an entry based on property?
  
  (Asked by: username_0 on 2016-08-05)
  
  Trying to pull in a limit of 2 events that are upcoming (so the event's eventDate should be newer than today). I currently have this:
  
  ```
  {% set entries = craft.entries.section('events').order('eventDate asc') %}
  {% set today = now|date('Y-m-d') %} 
  
  {% for event in entries %}
    {% if today <= event.eventDate %}
      <!-- markup here -->
    {% endif %}
  {% endfor %}
  
  ```
  
  However, this returns all events that are upcoming. I would like to only limit it to 2. The problem when I put the .limit(2) on my for loop is that it chooses the first two (and those happen to be older events). Do I need to do another loop within the if statement and add .limit(2) to that or is there a better way?
  
  Thanks!
  
  **Tags:** entry
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-08-05. Score: 5 | Accepted answer
  
  This should work below. Rather than querying all entries and looping through, just select the entries you need (ie. `now`) and limit them.
  
  ```
  {% set upcomingEvents = craft.entries.section('events').eventDate('>= '~now).limit(2) %}
  {% for event in upcomingEvents %}
      <!-- markup here -->
  {% endfor %} 
  
  ```
  
  > **Comments:**
  > **username_0**: Hi, thanks. Just tried this but its giving me a "Fatal error: Call to a member function getTimestamp() on boolean" with a large call stack table.  
  > **username_0**: Should also clarify that the date I need to make sure it's displaying after today is the eventDate of the entry (a custom field I set) and not the published or posted date.  
  > **username_2**: I guess `.after('>= '~now)` should be `.eventDate('>= '~now)`, otherwise this looks solid.  
  > **username_0**: Yes!! Thanks! Using ".eventDate(...)" worked for me. Appreciate the help!!  
  
  ---
  
  