1

I have a date field in the template. It's value is set to 4/8/2018. However, when I see the item's raw value, Sitecore converts it into UTC and stores it like 20180407T183000Z. The same value is indexed into the Solr.

Now the problem is: when I do a search for date >= 4/8/2018 no results are found. When i do a search for date >= 4/7/2018 there are items found. How to handle this? Could anyone help?

0

I had this issue with a Lucene index a few years ago (might be similar in Solr). The issue is the timestamp. Sitecore uses UTC as you have noticed to index the date which will set a time (based on the time difference to utc). When you query for the date, you also need to convert to utc in your query.

In our case, that wasn't even enough as there was a 'bug' in our version (8.1) with casing in the stored dates. The dates were stored uppercase but the query used lowercase.

We had 2 possible solutions:

  • use a format (like yyyyMMdd) on the date (not storing the time anymore) in the index definition
  • override the Sitecore.ContentSearch.Converters.IndexFieldUTCDateTimeValueConverter class to store the dates lowercase

You can read all details about this on my blog. Note that even if it is this isssue: as mine was on Lucene the exact solution syntax might be a little different on Solr. But it should set you on the right track.

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.