SharePoint Calendar view with date formatting

by Mark Wiseman on December 22nd, 2010 | Posted in Revium Sandbox | Read the comments

On one of our recent SharePoint implementations our client, like most, wanted to take advantage of the calendar functionality. They had 2 simple requirements:

  1. Have a separate page for the calendar
  2. List the next 5 events on the homepage

This was very simple to do but the issue we encountered was on the homepage. Whenever a full day event was displayed it was showing a start time of 12am. Since we can’t change this value they didn’t want it to be displayed.

So I thought we could make a simple calculated column (based on [All Day Event]) to display just the date.
i.e.

=IF( [All Day Event],
    /*Short Start Date*/,
    /*Long Start Date Time*/)

=IF( [All Day Event],
    TEXT(DATE(YEAR([Start Time]), MONTH([Start Time]),DAY([Start Time])),"dd/mm/yyyy"),
    TEXT([Start Time],"dd/mm/yyyy hh:mm AM/PM"))

Unfortunately we don’t have access to [All Day Event]

So I next thought we could just check the see if the event goes for a multiple of 24 hours (1 day, 2 days, 3 days)

=IF(MOD(ROUNDUP(([End Time]-[Start Time])*24,0),24)=0,
    TEXT(DATE(YEAR([Start Time]), MONTH([Start Time]),DAY([Start Time])),"dd/mm/yyyy"),
    TEXT([Start Time],"dd/mm/yyyy h:mm AM/PM"))

But this solution treats events that start and end at the same time (people do do it) as all day events. So we need to also check for this condition:

=IF(NOT([End Time]=[Start Time]),
    IF(MOD(ROUNDUP(([End Time]-[Start Time])*24,0),24)=0,
        TEXT(DATE(YEAR([Start Time]), MONTH([Start Time]),DAY([Start Time])),"dd/mm/yyyy"),
        TEXT([Start Time],"dd/mm/yyyy h:mm AM/PM")),
    TEXT([Start Time],"dd/mm/yyyy h:mm AM/PM"))

This beast of a calculated column gets the time display we want

Related posts:

  1. SharePoint backup script using PowerShell
  2. Windows SharePoint Services Help Search – SPSearch Starting Error
  3. Asp.Net MVC convert View to Word Document
  4. SharePoint – CSV Default File Action
  5. Sharepoint – Getting Photos from People and Groups

Tags: sharepoint

« Modified properties in LINQ to SQL

ASP.NET MVC3 – Application_Error not firing log4net »

One Response to “SharePoint Calendar view with date formatting”

  1. Yair says:
    November 29, 2012 at 5:55 pm

    Thank you so much! I was about to kill myself over this default formatting :)
    Worked like a charm!

Leave a Reply

Click here to cancel reply.

Recent Articles

  • ISAF Sailing World Cup
  • Revium Supports the Prostate Cancer Foundation of Australia
  • Kentico FAQ Module
  • Advanced Visitor Tracking in Analytics
  • Kentico, Smart Search and filtering attachments
  • Enhancing JIRA’s Issue Navigator
  • Mobile Browsing
  • Revium help win gold for Australia

Twitter

  • All things Gold! http://t.co/9DkkjmAr 2012-09-13
  • Mat Belcher - our favourite London Gold Medalist dropped into the office to say thank you. http://t.co/TxHbe2y6 2012-09-13
  • You beauty - http://t.co/1kbcBZwg #london2012 @belcherpage2012 2012-08-10
  • More updates...

Revium Logo

  • Home
  • About
  • Expertise
  • Showcase
  • Contact

  • news
  • blog
  • sandbox
  • twitter
  • rss
  • visit our facebook page

We are Revium, hear us roar!

The news.

26 Feb

Revium Supports the Prostate Cancer Foundation of Australia

We here at Revium are proud to say that we are supporting the Prostate Cancer Foundation of Australia, this month we have been able…

Continue reading
View archive

The blog.

11 Apr

ISAF Sailing World Cup

Mat Belcher and his team have been successful in taking out round 3 of the ISAF Sailing World Cup in Palma de Mallorca a…

Continue reading
View archive

The sandbox.

20 Dec

Kentico, Smart Search and filtering attachments

We had a scenario recently where we had 2 indexes set up in Kentico to search different folders within our site. Everything worked as…

Continue reading
View archive

eNewsletter.

 

© Copyright 2013. All Rights Reserved.

Revium Pty Ltd

info@revium.com.au Work +61 3 9429 2000

10 Harvey Street
Richmond, Victoria, 3121 Australia
View map

Disclaimer and privacy Revium Pty Ltd

Find us: web development, seo

 
Partner logos