Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please specify DateTime conversion fully #19284

Closed
ishepherd opened this issue Nov 21, 2018 — with docs.microsoft.com · 10 comments
Closed

Please specify DateTime conversion fully #19284

ishepherd opened this issue Nov 21, 2018 — with docs.microsoft.com · 10 comments

Comments

Copy link
Contributor

I suspect that the second fraction always has 7 digits and is always followed by a Z. Please confirm?

We have had an issue recently from inexact string/date comparison in cosmos queries, so I'd like this to be firmly specified


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@Mike-Ubezzi-MSFT
Copy link
Contributor

@ishepherd Thank you for the detailed feedback. I have assigned this to the content author to evaluate and update as appropriate.

@ishepherd
Copy link
Contributor Author

Simpler version of the question:

Are you using the .NET DateTime "o" format to make the ISO 8601 conversion?

I would check myself but the library is closed source.

@SnehaGunda
Copy link
Contributor

@ishepherd Sorry abou the delay in getting back on this, we use the ISO data format: https://en.wikipedia.org/wiki/ISO_8601 you have to serialize the datetimeoffset as a lexographically sorted string in order for Cosmos DB to complete the operation.

We will now close this issue, if you have further questions feel free to reopen.

@SnehaGunda
Copy link
Contributor

#please-close

@ishepherd
Copy link
Contributor Author

Hi @SnehaGunda, please don't close. Here is an example:

Say I have a document with

Time =  "2018-01-01T00:00:00.0001Z"

and I run a query WHERE

Time <= "2018-01-01T00:00:00.00010Z"

This query will not match the document. The strings are equal times, but they are not equal lexicographically, due to the different decimal places. ISO 8601 does not specify decimal places.

Therefore please answer,

Are you using the .NET DateTime "o" format to make the ISO 8601 conversion? [7 decimal places]

@ishepherd
Copy link
Contributor Author

@MarileeTurscak-MSFT Please reopen. @SnehaGunda said I could reopen if question not answered, but I guess I do not have rights to do it.

Sneha, please see my comment above #19284 (comment)

@Mike-Ubezzi-MSFT
Copy link
Contributor

@ishepherd Understand that you are seeking a product related question. This channel is for addressing documentation related issues. Please take a look at the the Cosmos DB MSDN threads related to date time conversion. If after researching this you are at a complete loss, please use the email alias: askcosmosdb@microsoft.com. Thank you.

Copy link

daxfohl commented Jan 3, 2019

@ishepherd It uses Newtonsoft under the hood, so thus it uses whatever global settings Newtonsoft is configured with. You can override these settings in the DocumenClient constructor, so if you create your DocumentClient with serializerSettings: new JsonSerializerSettings { DateFormatString = "o" }, it'll fix the problem. Ick, but so it goes.
@Mike-Ubezzi-MSFT and @SnehaGunda this seems like something worth documenting, as it is far from obvious that this would be necessary, and it breaks DateTime sort order without it. Given this is the canonical document on how to use DateTime in Cosmos DB, this guidance should be here.

@ishepherd
Copy link
Contributor Author

👍 @daxfohl but note that serializerSettings is not a full solution because of Azure/azure-cosmos-dotnet-v2#351.

@daxfohl
Copy link

daxfohl commented Jan 5, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants