<p>Within the context of <code>calendar.month</code>, if you check out the demo templates, we style the beginning and end of multi-day events with the following code:</p>

<pre><code>{% if event.multiDay %}
    {% set classes = classes ~ " multi_day" %}
    {% set classes = classes ~ (day.containsDate(event.startDateLocalized) ? " first_day") %}
    {% set classes = classes ~ (day.containsDate(event.endDateLocalized) ? " last_day") %}
{% endif %}
</code></pre>

CC BY-SA 4.0
2019-03-27T15:51:51.117Z
Excellent! Thanks - I must've missed that in the demo templates.
A Herrera
CC BY-SA 4.0
2019-03-27T21:57:05.483Z
This is almost fully working. The bit that doesn't work is the "first_day" class per your example. Even in the demo templates the class for the first day isn't applied. Any ideas?
A Herrera
CC BY-SA 4.0
2019-03-27T21:58:04.190Z
Screenshot of the demo templates in my setup here: https://d.pr/i/a0T1BV
A Herrera
CC BY-SA 4.0
2019-03-28T14:10:14.867Z
Perhaps try reinstalling demo templates. Multi-day events appear to display correctly for me...
Solspace
CC BY-SA 4.0
2019-04-01T17:09:40.457Z
Hm, that didn't work.
A Herrera
CC BY-SA 4.0
2019-04-02T20:24:23.403Z
I'm going to guess your event is 2 days long? I am looking back at my test site and it appears this works smoothly for events 3 days or longer, but has trouble with the first of 2 days. Checking into that... EDIT, just saw your screenshot shows 3-day event...
Solspace
CC BY-SA 4.0
2019-04-02T20:43:53.737Z
Okay, it seems to only work correctly for multi-day events that are not All Day events. It would seem that this is acting as "intended", according to the docs, but obviously this is an oversight. I have made a note about this and we'll address it in the near future. :)
Solspace
CC BY-SA 4.0
2019-04-03T16:38:42.573Z
Okay cool, thank you!
A Herrera
CC BY-SA 4.0
2019-04-03T20:18:39.250Z
I've updated the solution... you'll want to just use `startDateLocalized` and `endDateLocalized` instead. This will work for you right now if you switch it. :)
Solspace
CC BY-SA 4.0
2019-04-15T20:34:35.333Z
Perfect, thanks!
A Herrera
CC BY-SA 4.0
2019-03-27T03:49:44.817Z
2019-04-03T20:18:54.480Z
2019-04-03T20:18:54.480Z
Solspace
<p>Is there a way to get the first and last days of a multi-day event? I want to be able to style the first and last days differently. I don't see anything like this in the docs.</p>

<p>This is in Craft 3 and Calendar 2.0.17</p>

<craft3><plugin-solspacecalendar><calendar><plugin-calendar>
Getting the first and last days of a multi-day event - Solspace Calendar
# Getting the first and last days of a multi-day event - Solspace Calendar

(Asked by: username_0 on 2019-03-26)

Is there a way to get the first and last days of a multi-day event? I want to be able to style the first and last days differently. I don't see anything like this in the docs.

This is in Craft 3 and Calendar 2.0.17

**Tags:** craft3, plugin-solspacecalendar, calendar, plugin-calendar

---

## 1 answers

### Answer by username_1 on 2019-03-27. Score: 1 | Accepted answer

Within the context of calendar.month, if you check out the demo templates, we style the beginning and end of multi-day events with the following code:
{% if event.multiDay %}
    {% set classes = classes ~ " multi_day" %}
    {% set classes = classes ~ (day.containsDate(event.startDateLocalized) ? " first_day") %}
    {% set classes = classes ~ (day.containsDate(event.endDateLocalized) ? " last_day") %}
{% endif %}

> **Comments:**
> **username_0**: Excellent! Thanks - I must've missed that in the demo templates.  
> **username_0**: This is almost fully working. The bit that doesn't work is the "first_day" class per your example. Even in the demo templates the class for the first day isn't applied. Any ideas?  
> **username_0**: Screenshot of the demo templates in my setup here: https://d.pr/i/a0T1BV  
> **username_1**: Perhaps try reinstalling demo templates. Multi-day events appear to display correctly for me...  
> **username_0**: Hm, that didn't work.  
> **username_1**: I'm going to guess your event is 2 days long? I am looking back at my test site and it appears this works smoothly for events 3 days or longer, but has trouble with the first of 2 days. Checking into that... EDIT, just saw your screenshot shows 3-day event...  
> **username_1**: Okay, it seems to only work correctly for multi-day events that are not All Day events. It would seem that this is acting as "intended", according to the docs, but obviously this is an oversight. I have made a note about this and we'll address it in the near future. :)  
> **username_0**: Okay cool, thank you!  
> **username_1**: I've updated the solution... you'll want to just use `startDateLocalized` and `endDateLocalized` instead. This will work for you right now if you switch it. :)  
> **username_0**: Perfect, thanks!  

---

