<p>You can do a certain amount of logic in the <a href="http://buildwithcraft.com/docs/templating/elementcriteriamodel#parameter-value-syntax" rel="noreferrer">ElementCriteriaModel syntax</a>. I think this will work:</p>

<pre><code>{% set entries = craft.entries.section('equipment').modelYear('and, &gt; 2006, &lt; 2009') %}
{% for entry in entries %}
  ...
{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-09-11T22:52:48.837Z
2014-09-11T22:52:48.837Z
Marion Newlevant
<p>I'm trying to return results based on a year stored in a custom field. For example, returning entries with a model year greater than 2006 and less than 2009. Is there a search syntax to support this?</p>

<p>For example: <code>for entry in craft.entries.section('equipment').search(modelYear: &gt; 2006 &amp;&amp; &lt; 2009) …</code></p>

<search><elementcriteriamodel>
Using search to display entries based on a value in a number field
# Using search to display entries based on a value in a number field

(Asked by: username_0 on 2014-09-11)

I'm trying to return results based on a year stored in a custom field. For example, returning entries with a model year greater than 2006 and less than 2009. Is there a search syntax to support this?

For example: `for entry in craft.entries.section('equipment').search(modelYear: > 2006 && < 2009) …`

**Tags:** search, elementcriteriamodel

---

## 1 answers

### Answer by username_1 on 2014-09-11. Score: 5 | Accepted answer

You can do a certain amount of logic in the ElementCriteriaModel syntax. I think this will work:
{% set entries = craft.entries.section('equipment').modelYear('and, > 2006, < 2009') %}
{% for entry in entries %}
  ...
{% endfor %}


---

