Body: <p>I am working with a template in Craft 2, and I am setting up the criteria for entries to be displayed.<br />
  Here is my code (below).</p>
  <pre><code>{% set today = now|date('Y-m-d') %}
  
  {% set criteria = {
      section: 'bulletin',
      order: 'postDate',
      expiryDate: '&gt;=' . today
  } %}
  
  {% set initialEntry = craft.entries(criteria).first() %}
  {% set finalEntry = craft.entries(criteria).last() %}
  </code></pre>
  <p>I get this error:</p>
  <pre><code>Impossible to access an attribute (&quot;today&quot;) on a string variable (&quot;&gt;=&quot;). 
  </code></pre>
  <p>How would I set expiryDate &gt;= today?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-31T19:12:59.143Z
Comments.Text: In Twig, `~` is the concatenation operator! You can also use `">= #{today}"`, which Twig refers to as "string interpolation." This looks fine, otherwise. 
Comments.UserDisplayName: August Miller
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-31T19:42:52.357Z
Comments.Text: Ah!  Thanks so much.  I was still in PHP mode.  :)
Comments.UserDisplayName: buck1112
Tags: <templating><entries><datetime><craft2>
Title: Craft 2 - Date Comparison In Criteria - Impossible to access an attribute ("today") on a string variable (">=")
ThreadText: # Craft 2 - Date Comparison In Criteria - Impossible to access an attribute ("today") on a string variable (">=")
  
  (Asked by: username_0 on 2022-01-31)
  
  I am working with a template in Craft 2, and I am setting up the criteria for entries to be displayed.  
  Here is my code (below).
  
  ```
  {% set today = now|date('Y-m-d') %}
  
  {% set criteria = {
      section: 'bulletin',
      order: 'postDate',
      expiryDate: '>=' . today
  } %}
  
  {% set initialEntry = craft.entries(criteria).first() %}
  {% set finalEntry = craft.entries(criteria).last() %}
  
  ```
  
  I get this error:
  
  ```
  Impossible to access an attribute ("today") on a string variable (">="). 
  
  ```
  
  How would I set expiryDate >= today?
  
  **Tags:** templating, entries, datetime, craft2
  
  > **Comments:**
  > **username_1**: In Twig, `~` is the concatenation operator! You can also use `">= #{today}"`, which Twig refers to as "string interpolation." This looks fine, otherwise.   
  > **username_0**: Ah!  Thanks so much.  I was still in PHP mode.  :)  
  
  ---
  
  ## 0 answers
  
  