Answers.Body: <p>You'd need to use Twig's <a href="https://twig.symfony.com/doc/2.x/templates.html#other-operators" rel="nofollow noreferrer">string concatenation</a> in order to do this with the <code>~</code> operator.</p>
  
  <pre><code>{% set entries = craft.entries.section('calendar').search('eventstart:' ~ year ~ '-' ~ month) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-06T22:20:01.473Z
Answers.LastActivityDate: 2017-10-06T22:20:01.473Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm trying to set up an archive page by passing dates in the URL to the entries search parameter to show events from a specific month.  The <code>eventstart</code> is a custom date field.  If I enter numbers i.e. 2017-11 in the search parameter it works but the URL segments don't seem to parse.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>{% set year = craft.request.segment(3) %}
  {% set month = craft.request.segment(4) %}
  
  {% set entries = craft.entries.section('calendar').search('eventstart:"year-month)"') %}
  
  {% for entry in entries %}
      &lt;h3&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/h3&gt;
  {% endfor %}
  </code></pre>
  
Tags: <search><archives>
Title: How do I pass a URL segment to a search parameter?
ThreadText: # How do I pass a URL segment to a search parameter?
  
  (Asked by: username_0 on 2017-10-06)
  
  I'm trying to set up an archive page by passing dates in the URL to the entries search parameter to show events from a specific month. The `eventstart` is a custom date field. If I enter numbers i.e. 2017-11 in the search parameter it works but the URL segments don't seem to parse.
  
  Thanks in advance.
  
  ```
  {% set year = craft.request.segment(3) %}
  {% set month = craft.request.segment(4) %}
  
  {% set entries = craft.entries.section('calendar').search('eventstart:"year-month)"') %}
  
  {% for entry in entries %}
      <h3><a href="{{ entry.url }}">{{ entry.title }}</a></h3>
  {% endfor %}
  
  ```
  
  **Tags:** search, archives
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-10-06. Score: 2 | Accepted answer
  
  You'd need to use Twig's [string concatenation](https://twig.symfony.com/doc/2.x/templates.html#other-operators) in order to do this with the `~` operator.
  
  ```
  {% set entries = craft.entries.section('calendar').search('eventstart:' ~ year ~ '-' ~ month) %}
  
  ```
  
  
  ---
  
  