<p>ElementCriteriaModel parameters always add up to further filter down the results, which means an element has to be truthy for each one of them to be returned.</p>

<p>So your params basically look right for what you're trying to achieve. The only thing that might mess with the results is the for me unusual use of the <code>w3c</code> methods on the DateTime objects, which might output in a format not supportet by the criteria model.</p>

<p>Try one of the following variants instead:</p>

<p><code>"&lt;= " ~ now.iso8601()</code><br>
<code>"&lt;= " ~ now|date('c')</code><br>
<code>"&lt;= " ~ now|date('U')</code></p>

<p>If you're not interested in ouputting the time, you could also just use:</p>

<p><code>"&lt;= " ~ now</code>  </p>

<p>which outputs the same as <code>"&lt;= " ~ now|date('Y-m-d')</code>.  </p>

CC BY-SA 3.0
2016-02-19T23:25:22.833Z
Hi Carlcs, Tnx for your reaction. I tested it with `"<= " ~ now|date('c')` and it works!
Martijn La Feber
CC BY-SA 3.0
2016-02-19T15:43:09.173Z
2016-02-19T15:43:09.173Z
carlcs
<p>I'm trying to make a query which has 2 conditions who has to be true both. In PHP I should use &amp;&amp; to get this. startdate &lt;= now &amp;&amp; enddate >= now. How do I write this in Craft twig?
Tnx in advance!</p>

<pre><code>{% set current = craft.entries.find({
    section:'exhibitions', 
    startdate : "&lt;= " ~ now.w3c(),
    enddate : "&gt;= " ~ now.w3c(), 
    order:'startdate'}) 
%}

{% if current|length %}
    Current exhibitions
    {% for exhibition in current %}
        {{ exhibition.title }}
    {% endfor %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2016-02-19T15:37:55.687Z
If  `startdate` and `enddate` are both date/time fields then you don’t need the `.w3c()` part, simply `now` should be enough.
Josh Angell
CC BY-SA 3.0
2016-02-19T23:26:36.323Z
Hi Josh, tnx for your reaction. I'm gonna check this out!
Martijn La Feber
<entries><queries><set>
How to write query with startdate <= now && enddate >= now?
# How to write query with startdate <= now && enddate >= now?

(Asked by: username_0 on 2016-02-19)

I'm trying to make a query which has 2 conditions who has to be true both. In PHP I should use && to get this. startdate <= now && enddate >= now. How do I write this in Craft twig?
Tnx in advance!
{% set current = craft.entries.find({
    section:'exhibitions', 
    startdate : "<= " ~ now.w3c(),
    enddate : ">= " ~ now.w3c(), 
    order:'startdate'}) 
%}

{% if current|length %}
    Current exhibitions
    {% for exhibition in current %}
        {{ exhibition.title }}
    {% endfor %}
{% endif %}

**Tags:** entries, queries, set
> **Comments:**
> **username_1**: If  `startdate` and `enddate` are both date/time fields then you don’t need the `.w3c()` part, simply `now` should be enough.  
> **username_0**: Hi Josh, tnx for your reaction. I'm gonna check this out!  

---

## 1 answers

### Answer by username_2 on 2016-02-19. Score: 4 | Accepted answer

ElementCriteriaModel parameters always add up to further filter down the results, which means an element has to be truthy for each one of them to be returned.

So your params basically look right for what you're trying to achieve. The only thing that might mess with the results is the for me unusual use of the `w3c` methods on the DateTime objects, which might output in a format not supportet by the criteria model.

Try one of the following variants instead:

`"<= " ~ now.iso8601()`  
`"<= " ~ now|date('c')`  
`"<= " ~ now|date('U')`

If you're not interested in ouputting the time, you could also just use:

`"<= " ~ now`

which outputs the same as `"<= " ~ now|date('Y-m-d')`.

> **Comments:**
> **username_0**: Hi Carlcs, Tnx for your reaction. I tested it with `"<= " ~ now|date('c')` and it works!  

---

