<p>It's probably because <code>entry.dayOfEvent</code> isn't returning exactly what <code>"now"|date_modify('+1 day')</code> is returning therefore the comparison fails.  Maybe one includes the time and the other doesn't, for example.</p>

<p>You can see what each is returning by doing:</p>

<pre><code>{{ entry.dayOfEvent }}
{{ "now"|date_modify('+1 day') }}
</code></pre>

<p>If they are different formats, then you can make the 2nd one match the format of the first by using <a href="http://twig.sensiolabs.org/doc/filters/date.html#date" rel="nofollow">Twig's date format method</a>.</p>

CC BY-SA 3.0
2014-10-01T12:11:39.847Z
thx for your input.. I updated the question in hope for further help.
eek-a-edge
CC BY-SA 3.0
2014-10-01T16:46:39.967Z
What are the possible values for `entry.dayOfEvent`?
Brad Bell
CC BY-SA 3.0
2014-10-01T16:58:14.933Z
I tried with day names and with the numbers 1-7 with the |date("N") format. The results are fine. If it's wednesday it show that day. If i switch it to numbers it show the number and the entries. It may work with [this plugin](https://github.com/marionnewlevant/craft-mnbreakandcontinue) i'm currently testing. But i get deleted entries returned. ex i created an event wednesday test that I deleted from the structure, but it still comes up in the results. It looks like the entry is still in the dB.
eek-a-edge
CC BY-SA 3.0
2014-09-30T21:57:30.343Z
2014-09-30T21:57:30.343Z
Brad Bell
<p>Building further on <a href="https://craftcms.stackexchange.com/questions/2826/targeting-entries-in-a-structure">this problem</a>, I try to make a loop that exits when the next opening hours or in other case events are found.</p>

<p>There is an event on all days except monday. I added a couple of extra elseif statements in case they drop a couple of events.</p>

<p>I have the following code (based on the answer below I changed my code)</p>

<pre><code>{% for entry in craft.entries.section('events').level(2) %}
  {% if entry.dayOfEvent == now|date("l") %}
    {{ entry.dayOfEvent }}
  {% elseif entry.dayOfEvent == now|date_modify("+1 day")|date("l") %}
    {{ entry.dayOfEvent }}
  {% elseif entry.dayOfEvent == now|date_modify("+2 days")|date("l") %}
    {{ entry.dayOfEvent }}
  {% elseif entry.dayOfEvent == now|date_modify("+3 days")|date("l") %}
    {{ entry.dayOfEvent }}
  {% else %}
{% endfor %}
</code></pre>

<p>But this doesn't seem to do it. It's probably basic stuff, but what am i doing wrong?</p>

<p><strong>Update</strong></p>

<p><em>Based on the answer below I changed my code</em></p>

<p>The output clearly gives me my days. But the {% elseif %} doesn't work, I just get the day outputted as well for all events in that range. Shouldn't it exit the loop as soon as the condition is met? </p>

<entries><datetime><forloop>
if/else loop with (almost) daily events
# if/else loop with (almost) daily events

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

Building further on this problem, I try to make a loop that exits when the next opening hours or in other case events are found.
There is an event on all days except monday. I added a couple of extra elseif statements in case they drop a couple of events.
I have the following code (based on the answer below I changed my code)
{% for entry in craft.entries.section('events').level(2) %}
  {% if entry.dayOfEvent == now|date("l") %}
    {{ entry.dayOfEvent }}
  {% elseif entry.dayOfEvent == now|date_modify("+1 day")|date("l") %}
    {{ entry.dayOfEvent }}
  {% elseif entry.dayOfEvent == now|date_modify("+2 days")|date("l") %}
    {{ entry.dayOfEvent }}
  {% elseif entry.dayOfEvent == now|date_modify("+3 days")|date("l") %}
    {{ entry.dayOfEvent }}
  {% else %}
{% endfor %}

But this doesn't seem to do it. It's probably basic stuff, but what am i doing wrong?
Update
Based on the answer below I changed my code
The output clearly gives me my days. But the {% elseif %} doesn't work, I just get the day outputted as well for all events in that range. Shouldn't it exit the loop as soon as the condition is met?

**Tags:** entries, datetime, forloop

---

## 1 answers

### Answer by username_1 on 2014-09-30. Score: 2

It's probably because entry.dayOfEvent isn't returning exactly what "now"|date_modify('+1 day') is returning therefore the comparison fails.  Maybe one includes the time and the other doesn't, for example.
You can see what each is returning by doing:
{{ entry.dayOfEvent }}
{{ "now"|date_modify('+1 day') }}

If they are different formats, then you can make the 2nd one match the format of the first by using Twig's date format method.

> **Comments:**
> **username_0**: thx for your input.. I updated the question in hope for further help.  
> **username_1**: What are the possible values for `entry.dayOfEvent`?  
> **username_0**: I tried with day names and with the numbers 1-7 with the |date("N") format. The results are fine. If it's wednesday it show that day. If i switch it to numbers it show the number and the entries. It may work with [this plugin](https://github.com/marionnewlevant/craft-mnbreakandcontinue) i'm currently testing. But i get deleted entries returned. ex i created an event wednesday test that I deleted from the structure, but it still comes up in the results. It looks like the entry is still in the dB.  

---

