Displaying a SharePoint calendar in your intranet/internet site is quite easy. You just add the calendar web part to the page and voilà!
Now, for the most columns in the calendar, this works just fine. To display a Yes for an All Day Event is an option. You don’t like it? Just remove the column from the view. But if you want to use and display All Day Events, the result can be annoying. Check this out:
See that begin and end time of the all day event? It start at
0:00 and ends at
23:59. Now that is pretty ugly to show to your website visitors, isn’t it?
So, what can you do?
One way of tackling this problem is changing the XSLT. But that can be complex and hard to get to work. I’ve chosen a different route and decided to create a calculated column that will render the date and time, depending on if the event is an all day event or not.
Unfortunately, the all day event column (
fAllDayEvent) is not available for use in a calculated column. So we need to find out ourselves what an all day event is.
And then I found this site: SharePoint Calendar view with date formatting
It really helped me with the formula to determine what an all day event is.
It did take me some time to realise that the formula contains an error; in the formulas, you need to use a semicolon (;) instead of a comma (,).
First, I made a calculated column (boolean: yes, no) to determine an all day event – AllDay:
=IF(NOT([End Time]=[Start Time]); IF(MOD(ROUNDUP(([End Time]-[Start Time])*24;0);24)=0; TRUE; FALSE); FALSE)
Why? So I can use this boolean column in other calculated columns…
Then I made the actual calculated column I want to display – StartDate:
=IF(AllDay; TEXT([Start Time]; "dd-MM-yyyy") & " (all day)"; TEXT([Start Time]; "dd-MM-yyyy h:mm"))
As you can see, if it’s a regular event, I’ll display date and time.
If it’s an all day event, I’ll display the date, followed by ” (all day)”.
And finally, I change the view of the calendar web part to display the StartDate column:
Much nicer, don’t you think?