4

I've created a metadata property called CalendarEventDate.
It is mapped to "ows_EventDate (DateTime)" or something like that.

I did a full crawl afterwards and when I checked the raw XML, I found that it only returned the Date portion of Date and Time. enter image description here

What's worse is that it is displaying the wrong date!
Here's the correct datetime from the list item: enter image description here

What should I do so that the XML returns the full Date and Time or at least the correct Date?


Update

I guess as a workaround, I could create calculated fields that store the Date and Time values, but I don't want to be adding extra fields if possible.

4
+50

DateFormat property is used for specifying the date and time formatting for the CoreResultsWebPart web part.

By default search results in the web part are displayed in DateOnly format.

Usage

This property could not be specified using web part editor, so please consider another options for specifying it value, for example SharePoint Designer or Export/Import web part.

For example, after specifying this property value to DateTime:

<property name="DateFormat" type="Microsoft.SharePoint.Utilities.SPDateFormat, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">DateTime</property> 

calendareventdate property would be displayed like this:

<calendareventdate>2/12/2013 12:58 PM</calendareventdate>
  • 1
    Thanks! I'm getting both the Date and Time now, but it's still the wrong date for some reason: <calendareventdate>24/12/2013 5:00 PM</calendareventdate>. It should be 25/12/2013 12:00 AM. I've checked other items and the same is true (e.g. I'm getting <calendareventdate>04/08/2013 6:00 PM</calendareventdate> for what is supposed to be 05/08/2013 12:00 AM). It looks to me that anything set to Month X, YYYY 12:00 AM is returned as Month (X-1), YYYY (5 or 6) PM. If the time is actually set to something other than 12:00 AM, it displays correctly. – kei Apr 7 '15 at 14:39
  • 1
    It seems the "All Day Event" flag is what is causing the problem here. When it is unchecked, the date and time are displayed correctly. Would you happen to know the fix for this? – kei Apr 7 '15 at 16:51
  • 3
    Indeed, most likely it is related with All Day Event flag. When this flag is set, the date is returned in GMT time and not the current time (!) I'm a little bit surprised since was thinking that this issue has been resolved by MS. More details: social.technet.microsoft.com/Forums/office/en-US/… – Vadim Gremyachev Apr 7 '15 at 17:32
1

SharePoint stores date value in UTC format. While rendering the data SharePoint converts it to local time and displays it correctly.

In your case the UTC date value is returned from Search. While displaying the data you should change it to local time (By customizing the XSLT etc.)

http://itblog.wolthaus.net/2011/09/sharepoint-stores-dates-in-utc-time/

For changing the display format you can use FormatDate option

ddwrt:FormatDate(@ArticleStartDate, 2057, 2)

That will display date in mm/dd/yyyy HH:MM AM/PM format.

  • I think that this has nothing to do with format, OP mentioned raw xml format – Vadim Gremyachev Apr 7 '15 at 12:43
  • 1
    I have misread the question. I think time for coffee break :) – Amal Hashim Apr 7 '15 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.