<p>Think you've just got a logic error in your Twig code.  This should work:</p>

<pre><code>{% set userInputtedNumber = 3000 %}

{% set entries = craft.entries({
    section: 'channel',
    numStart: '&lt;=' ~ userInputtedNumber,
    numEnd: '&gt;=' ~ userInputtedNumber,
}) %}
</code></pre>

CC BY-SA 3.0
2017-09-27T04:06:33.520Z
Urg I knew it was going to be something simple! I copied this logic from some php and didn't make the needed adjustments. Thank you!
MikeeBee
CC BY-SA 3.0
2017-09-27T00:18:43.347Z
2017-09-27T00:18:43.347Z
Brad Bell
<p>I have imported entries, each with 2 fields that comprise a range of numbers... <code>numberStart</code> and <code>numberEnd</code>. e.g. <code>3000 - 3006</code>, in some instances both are the same number e.g. <code>8001 - 8001</code> The user will be inputting a single number and I need to return the single entry where the inputted number lands between (or is equal to) the start and (or) end number.</p>

<p>This is what I have so far...</p>

<pre><code>{% set userInputtedNumber = 3000 %} 

{% set entries = craft.entries({
    section: 'section',
    numberStart: '&gt;=' ~ userInputtedNumber,
    numberEnd: '&lt;=' ~ userInputtedNumber,
}) %}
</code></pre>

<p>This just returns nothing as the operators clash.</p>

<p>Any ideas will be welcomed!</p>

<comparisons>
Check number against 2 seperate fields and return the entry that matches
# Check number against 2 seperate fields and return the entry that matches

(Asked by: username_0 on 2017-09-26)

I have imported entries, each with 2 fields that comprise a range of numbers... numberStart and numberEnd. e.g. 3000 - 3006, in some instances both are the same number e.g. 8001 - 8001 The user will be inputting a single number and I need to return the single entry where the inputted number lands between (or is equal to) the start and (or) end number.
This is what I have so far...
{% set userInputtedNumber = 3000 %} 

{% set entries = craft.entries({
    section: 'section',
    numberStart: '>=' ~ userInputtedNumber,
    numberEnd: '<=' ~ userInputtedNumber,
}) %}

This just returns nothing as the operators clash.
Any ideas will be welcomed!

**Tags:** comparisons

---

## 1 answers

### Answer by username_1 on 2017-09-27. Score: 0 | Accepted answer

Think you've just got a logic error in your Twig code.  This should work:
{% set userInputtedNumber = 3000 %}

{% set entries = craft.entries({
    section: 'channel',
    numStart: '<=' ~ userInputtedNumber,
    numEnd: '>=' ~ userInputtedNumber,
}) %}

> **Comments:**
> **username_0**: Urg I knew it was going to be something simple! I copied this logic from some php and didn't make the needed adjustments. Thank you!  

---

