Answers.Body: <p>I think you've just got a logic problem.</p>
  
  <pre><code>{% if entryStart &gt;= present and entryEnd &lt;= present %}
  </code></pre>
  
  <p>The only way this will ever evaluate to <code>true</code> is if the <code>entryStart</code> and <code>entryEnd</code> DateTime fields have the exact same date and time (down to the second) that the present time is, which seems like a very small window.</p>
  
  <p>You're essentially looking for an entry that lives in the future <em>and</em> in the past.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-23T11:03:52.200Z
Answers.Text: would changing it to {% if entryStart <= present and entryEnd >= present %} fix what I'm trying to do? Been working on these things for a while and just need another set of eyes to make sense of it.
Answers.UserDisplayName: Chattervast
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-23T23:56:20.660Z
Answers.Text: Can you explain in words when you'd want the entry information to be shown.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-19T14:39:23.763Z
Answers.Text: your solution fixed this problem. my logic was just incorrect.
Answers.UserDisplayName: Chattervast
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-23T00:00:09.633Z
Answers.LastActivityDate: 2016-09-23T00:00:09.633Z
Answers.UserDisplayName: Brad Bell
Body: <p>I need to display an entry only if the date fields within its Matrix are current. So, only display if the <code>startDate</code> is greater than or equal to today and the <code>endDate</code> is less than or equal to today.</p>
  
  <p>Currently I have this code and am having trouble finding how to compare multiple dates.</p>
  
  <pre><code>{% for entry in craft.entries.section('sectionHandle') %}
      {% set present = now|date %}
      {% set entryStart = entry.matrixHandle.startDate %}
      {% set entryEnd = entry.matrixHandle.endDate %}
  
      {% if entryStart &gt;= present and entryEnd &lt;= present %}
          display entry information
      {% endif %}
  {% endif %}
  </code></pre>
  
  <p>I'm guessing that I'm using the operators incorrectly or that "and" isn't allowed. Either way, it's not displaying anything and yes, I have a made sure that I have an entry with dates that would activate this if statement.</p>
  
Tags: <entry><datetime><forloop>
Title: Comparing current date to multiple entry matrix date fields
ThreadText: # Comparing current date to multiple entry matrix date fields
  
  (Asked by: username_0 on 2016-09-21)
  
  I need to display an entry only if the date fields within its Matrix are current. So, only display if the `startDate` is greater than or equal to today and the `endDate` is less than or equal to today.
  
  Currently I have this code and am having trouble finding how to compare multiple dates.
  
  ```
  {% for entry in craft.entries.section('sectionHandle') %}
      {% set present = now|date %}
      {% set entryStart = entry.matrixHandle.startDate %}
      {% set entryEnd = entry.matrixHandle.endDate %}
  
      {% if entryStart >= present and entryEnd <= present %}
          display entry information
      {% endif %}
  {% endif %}
  
  ```
  
  I'm guessing that I'm using the operators incorrectly or that "and" isn't allowed. Either way, it's not displaying anything and yes, I have a made sure that I have an entry with dates that would activate this if statement.
  
  **Tags:** entry, datetime, forloop
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-09-23. Score: 2 | Accepted answer
  
  I think you've just got a logic problem.
  
  ```
  {% if entryStart >= present and entryEnd <= present %}
  
  ```
  
  The only way this will ever evaluate to `true` is if the `entryStart` and `entryEnd` DateTime fields have the exact same date and time (down to the second) that the present time is, which seems like a very small window.
  
  You're essentially looking for an entry that lives in the future *and* in the past.
  
  > **Comments:**
  > **username_0**: would changing it to {% if entryStart <= present and entryEnd >= present %} fix what I'm trying to do? Been working on these things for a while and just need another set of eyes to make sense of it.  
  > **username_1**: Can you explain in words when you'd want the entry information to be shown.  
  > **username_0**: your solution fixed this problem. my logic was just incorrect.  
  
  ---
  
  