Forum
Compare date months in a Runway Collection
Hi,
I have a Runway Collection of events, each with a start and end date. I want to display these differently depending on those dates. There are 3 scenarios I want to test for:
- Start and End Date are the same
- Start and End Date are different but in the same month
- Start and End Date are different and in different months
I have event_start_date
and event_end_date
fields as part of the collection template which are standard Perch type="date"
.
I am using perch:if
statements in the template to test for this. First one is fine:
<perch:if id="event_start_date" match="eq" value="{event_end_date}">
<!-- This event is one day -->
</perch:if>
<perch:if id="event_start_date" match="neq" value="{event_end_date}">
<!-- This event is multiple days -->
</perch:if>
However I am not sure how to check for whether the months are the same or different. I tried this:
<perch:if id="event_start_date" match="neq" value="{event_end_date}">
<!-- This event is multiple days -->
<perch:if id="event_start_date_month" match="eq" value="{event_end_date_month}">
<!-- This event starts and ends in the same month -->
<perch:else>
<!-- This event starts and ends in different months -->
</perch:if>
</perch:if>
But the nested second perch:if
statement is not working.
How can I check if the start and end dates are in different months?
Thanks as always
Mike
You can use the
format
attribute withdifferent
. The formatting is applied before the dates are compared.