0

One of our SP2013 site have publishing feature enabled. There is a site column "Article Date" with field name "ArticleStartDate".

By search "article" in managed properties list I found a field "ArticleStartDateOWSDATE". Out of my expectation its datatype is "text" not datetime. By default, it is mapped to crawled property "ows_q_DATE_ArticleStartDate".

I go ahead to setup search with it. I found the search is weird. In order to search out an item with Article date on 2013/08/24 I have to query with "ArticleStartDateOWSDate:2013/08/23" (no typo here, I have to input 1 day earlier)

Is it a known bug or some of my farm's special issue?

5

Most of the default managed properties in Search are based upon the text datatype.

We noticed the same problem when sorting the search results on 'ArticleStartDateOWSDATE'. The sort order was not correct due to the text datatype.

We simply solved it by creating a new managed property 'ArticleStartDateOWSDATE2' with the same settings but with the correct datatype.

  • In fact I do the same thing. I created a managed property 'NewsArticleDate', type is date/time and mapped to 'ows_q_DATE_ArticleStartDate'. But I need to search by input 1 day earlier. – Mark L Jun 12 '14 at 8:00
  • By search ''NewsArticleDate=2013/6/18' I reutrn all result which 'Article Date' = 2013/6/19 – Mark L Jun 12 '14 at 8:08
  • 1
    Not sure what you mean. If you are getting results back from an incorrect date. Keep in mind dat the dates are stored in the GMT Timezone. If you run code against the Search you will need to include a timezone conversion yourself. – Wout Jun 12 '14 at 12:11
  • May you give me some guide how to make the conversion? – Mark L Jun 13 '14 at 5:09
  • see below for a sample on how to convert a datetime to the correct timezone – Wout Jun 13 '14 at 7:11
1

In addition to the question asked in de comments of the answer. Here is how to convert a datetime to the correct datetime of the timezone of the SharePoint website.

SPRegionalSettings regionalSettings = SPContext.Current.RegionalSettings;
SPTimeZone timeZone = regionalSettings.TimeZone;  // Timezone of the current website
DateTime dateFromSearch= (DateTime) row[column];   // this date is in GMT/UTC timezone.
DateTime localTime = timeZone.UTCToLocalTime(dateFromSearch);

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.