2

I'm started using azure search service and i have roadblock for now. I have modified-by column in my native DB table, which is actually part of my retrieve data from azure search. Native DB column always has date time in UTC format now when we retrieve BL layer does the conversion based on User Locale.

Do we have anyway to convert UTC to locale date in azure search as my search is independent and not passing through my BL layer to avoid slow down in search.

user1220402
  • 239
  • 1
  • 14

1 Answers1

1

Azure Search accepts date/time values with full time zone information (Edm.DateTimeOffset -- e.g. 2012-12-03T07:16:23-07:00) and then normalizes them to UTC for storage purposes. Azure Search itself will not convert date/times to different time zones for you. 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.

If your search client is a browser, then maybe this solution will work for you: Convert UTC date time to local date time using JavaScript

Community
  • 1
  • 1
Bruce Johnston
  • 8,344
  • 3
  • 32
  • 42
  • In reality, Azure Search converts all date/times to UTC. I've just faced that issue. I looked at HTTP requests set to the service, and the date/time/offset are fully passed. But when I search for documents (even at the portal), I see date/times in UTC format with no offset. That's pretty confusing. – sich Jan 12 '17 at 18:11
  • For example, in the request I have "DateTime": "2016-09-13T13:23:42-05:00". But when I search, I see "DateTime": "2016-09-13T18:23:42Z" in the document. – sich Jan 12 '17 at 18:13
  • @Andriy Savin: Thanks for pointing that out. I missed that went I first wrote this answer. I'll update it. – Bruce Johnston Jan 12 '17 at 18:19
  • But isn't that a bug? Nowhere in the docs mentioned that the returned time will not be exactly the added time. – sich Jan 12 '17 at 18:24
  • It is the same time, it's just in UTC instead of the original time zone. I'll make sure the docs mention this. Preserving the original time zone would be a pretty big change due to the way datetime values are stored currently. – Bruce Johnston Jan 12 '17 at 22:19
  • Yes, logically its the same time. But in my case in certain scenarios I use search results as primary source of data, while there is another data storage which persists time with offset. When I'm trying to match the same time from the search results and from that another storage as time with an offset, the times don't match. Thank you for clarification, will use UTC time for all operations now. – sich Jan 12 '17 at 22:35