1,804 articles and 15,097 comments as of Saturday, June 4th, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint content all in one place!

This site is a historical archive and is no longer being updated. Please update your favorites, bookmarks and RSS feeds.

NothingButSharePoint.com
Wednesday, January 7, 2009

Any way to have MOSS list the time range of an event in a Calendar View of a list instead of just the start time?

This question of the day comes from iamspartacus in Stump the Panel.

Any way to have MOSS list the time range of an event in a Calendar View of a list instead of just the start time? Need to create an after hours schedule that shows start and end times but don’t really want to buy Calendar Plus if I don’t have to.

My solution: Create a calculated column to display as ‘Month View Title’:

=[Title]&" : "&TEXT([Start Time],"h:mm")&"-"&TEXT([End Time],"h:mm")</pre>
Or, if you prefer 12-hour time format:
<pre lang="javascript">=[Title]&" : "&TEXT([Start Time],"h:mm AM/PM")&"-"&TEXT([End Time],"h:mm AM/PM")

Next, use a little jQuery/JavaScript to remove the default Start Time:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
	$("td.ms-cal-monthitem> a")
		.find("nobr").remove()
		.end()
		.find("br").remove();
});
</script>

Paul Grenier

 

Please Join the Discussion

34 Responses to “Any way to have MOSS list the time range of an event in a Calendar View of a list instead of just the start time?”
  1. Lynda says:

    Okay. I’ll ask the dumb question. To get the “little jQuery/JavaScript” in there, you have to find and edit the event file, right? Which also requires that you have access TO those files?

    The adding of the calculated column can be done with OOB but not the “little jQuery/JavaScript”. Right?

  2. AutoSponge says:

    @Lynda,

    I don’t even know what an event file is. Copy and paste the exact code into a CEWP and it will work–that’s it, no changing system files or needing access above site contributor.

    Here’s a link to a video I did of another solution: http://video.msn.com/video.aspx?vid=cf997972-7b0c-49d8-8fbf-52127d46512d

  3. Nick says:

    Paul,

    This is great, exactly what I have been looking for. However, when I do this, all that happens is the Start Time is removed from the calendar, the Title remains, and the calculated column doesn’t show.

    Is there something I need to do in the jQuery to add that calculated column to the calendar?

    Thanks,
    Nick

  4. Nick says:

    Nevermind, I am an idiot. Just have to change that in the view.

  5. Nick says:

    I do have another question though. Is there a way I can make it so this does not apply to all day events?

  6. Nick says:

    Well I answered my own question. If you want this to display only for events that aren’t all day, use this equation in the calculated column:

    =IF([End Time]-[Start Time]<0.999,Title&” : “&TEXT([Start Time],”h:mm”)&”-”&TEXT([End Time],”h:mm”),Title)

    Has to be .999 instead of 1 because sharepoint sets an all day event from 12:00am to 11:59pm.

    Hope this helps someone, definitely helped me.

  7. Ashu says:

    After seeing and trying a lot of these JQuery stuff I finally tried it. The problem I am having is that my site is SSL and it doesn’t like loading query file because of that.

    Is there a SSL version or will I have to copy the JS to my server to do it properly?

  8. AutoSponge says:

    @Ashu,

    For SSL sites, download the file from Google and place it in a document library where everyone can access it. Then change the script tag to have the local SRC path.

    See my article: http://www.endusersharepoint.com/?p=980

    I talk about a “contingency script” but you can also use that as the default.

  9. Daniel says:

    Get it in German Sharepoint and with switched order:

    =TEXT(Anfangszeit;”hh:mm”)&”-”&TEXT(Endzeit;”hh:mm”)&” : “&Titel

  10. AutoSponge says:

    @Nick,

    That’s a great tip! I didn’t realize a full-day event was only .999 of a day :)

  11. Dred says:

    I too ran into the problem that now I see the event listed in the calendar but no times. I added the calculated field and the CEWP. Could you specify what needed to be changed in the view? Thanks

  12. Dred says:

    nm. i took off my blinders so i can see my hands in front of my face.

  13. Dred says:

    only problem i have now is that the all day events use the GMT setting so my times show 19:00 – 18:59. i could reset the regional settings at the site level but is there something for just the calendar?

  14. AutoSponge says:

    @Dred,

    I don’t think you mean GMT, I think you mean military format. If you use the second calc column formula, it will display AM/PM format.

  15. Charlotte says:

    To add the end time field to all Calenders (month view) in your site collection ad once, this msdn article provides another solution.

    http://social.msdn.microsoft.com/Forums/en-US/sharepointcustomization/thread/179c74de-525c-4236-83cf-91861e9a7aee/#page:1

  16. Jason Walters says:

    I found a small bug in this. If you set the time span from say 11pm to 2am, then the time shows up as 2am – 11pm instead of 11pm to 2am.

  17. AutoSponge says:

    @Jason,

    That’s not a bug with the formula. It’s not possible to start something at 11pm and end at 2am on the same date. 2am means you’ve moved into the next day.

    So, if you look at the form again, SP has reversed the dates you entered assuming you made a mistake. The formula only returns the form’s values.

    If you enter the dates and times in the right order, SP will not change your values and the time span will appear as you expected.

  18. backtrack says:

    Hi,
    I’d like to have displayed on the calendar view the Creator (Created By) and another field like Location.
    The problem is that is not possible to choose Created By in a calculated column.
    Is there a solution for this?

    thanks
    andrew

  19. AutoSponge says:

    @backtrack

    I think you have to create a new field that gets filled by an SPD workflow (on create) with the Author’s name. Then you can use it in a column calculation.

  20. backtrack says:

    @AutoSponge

    Thanks a lot for the tip!
    I have added an “Update item” action in SPD that fills a “single line of text” column with the CreatedBy of the current item. Then i created a calculated column that can use that and another field.
    The only thing is that it writes the creator as “domain\username”, instead the default calendar view Created By shows the nicer readable “surname name”.

    have you got maybe another tip? :)

  21. AutoSponge says:

    Hmm. I think if your target field is a Person type you can choose to display ID, user name, SIP, etc.

    But I’ve also heard of people having problems updating Person columns in SPD.

    What data type did you go with?

  22. backtrack says:

    the target field is “single line of text” type because “Person or Group” type cannot be used in a calculated column.
    I need to use a calculated column to combine the name and the location which must both be “single line of text” type.
    So in SPD when I choose which value to assign the new field, I select CreatedBy of current item (and selected the proper list)

  23. Jamie Ayer says:

    Use Web services and xpath…

    1. path data connection:
    https://site/_vti_bin/UserProfileService.asmx?WSDL

    2. Web Service
    GetUserProfileByName

    3. Textbox field
    concat(xdXDocument:GetDOM(”GetUserProfileByName”)/dfs:myFields/dfs:dataFields/s0:GetUserProfileByNameResponse/s0:GetUserProfileByNameResult/s0:PropertyData/s0:Values/s0:ValueData/s0:Value[../../../s0:Name = "FirstName"], ” “, xdXDocument:GetDOM(”GetUserProfileByName”)/dfs:myFields/dfs:dataFields/s0:GetUserProfileByNameResponse/s0:GetUserProfileByNameResult/s0:PropertyData/s0:Values/s0:ValueData/s0:Value[../../../s0:Name = "LastName"])

  24. arrif says:

    It’ doesn’t work in french. I have a problem syntax of the formula.

    Thank’s to replay

  25. matt says:

    I have put in the top guide mentioned to get the start/end date in however it does this but it also prefixes the date with “string;#” which looks horrible, is there anyway to remove this?

  26. .ivan. says:

    Great information.

    I was just having issues with the second part. Where is the CEWP located in the calendar page. I just can’t seem to find where to put the code.

  27. .ivan. says:

    Nvm. I actually did a little more reading and realized that I had to add the web part.

  28. .ivan. says:

    Is there anyway to add a CEWP to the default.aspx to add the end time there as well?

  29. AutoSponge says:

    @.ivan

    You can add a CEWP to the defaut.master. Christohpe has a good article about that approach here: http://pathtosharepoint.wordpress.com/2009/02/15/a-content-editor-web-part-for-every-home/

    Just be careful. This will be on EVERY page. Since I didn’t test it on other pages, it may need modification to avoid changing something unintentionally.

  30. Vicki P says:

    Any ideas on what to do with Recurring Events? I cannot get the time to display correctly on these. I’ve also put out a plea for help on Stump the Panel, too!!

  31. iamspartacus says:

    Hello all (and hopefully Autosponge)!

    The script for removing the default Start Time from a Calendar, that Autosponge provided a year ago, was working great but has since stopped working – the default Start Time is now showing up again in my calendars.

    Did something change at the script source?

    iamspartacus

  32. AutoSponge says:

    @ iamspartacus,

    Check to make sure your version of jQuery is still available. This was written a while back, jQuery 1.4 is out now, so you may need to update the link.

  33. Tasha says:

    I tried the fix for this (that is, updating the link) and it still did not work. I even downloaded the .js file and referenced it internally with no luck. Has anyone gotten this to work recently? (So i can tell if it is something i’m doing wrong or perhaps this function somehow got dropped?)

    Thanks for any help anyone can offer!
    Tasha

  34. Tim says:

    This is a great fix. I do have one issue though. When I have 4 or more events in a day on the Monthly view I lose the “more item(s)” link. The expand all link will show all of the events. The issue is if there is no visual indicator, my endusers will not even think to check. Any ideas?

    Thanks,

    Tim


Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!