question

Irene-5235 avatar image
0 Votes"
Irene-5235 asked ajkuma-MSFT answered

Auto date convertion to local datetime on Cognitive search index issue

Our backend database is Mongodb and it stores date as UTC format by default. When we create the cognitive search indexes, it grabs the UTC date. This causes issues when we do the search as we need to search based on our local datetime. Is there anyway to auto convert the date coming from cognitive search index to local datetime if the source is UTC date format?

azure-cognitive-search
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered

@Irene-5235,

Azure Search accepts date/time values with full time zone information (`Edm.DateTimeOffset)` and then normalizes them to UTC for storage purposes. Azure Search itself will not convert date/times to different time zones. If you need to convert for the locale of each user on a per-search basis, then you will need to do the conversion on the client side.

Please see the doc for more information: Edm.DateTimeOffset - Mapping between JSON Data Types and Azure Cognitive Search Data Types

If your search client is a browser, you may implement this solution : Convert UTC date time to local date time using JavaScript | ref.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.