-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Most applications can use the default string representation for DateTime? #65079
Comments
Newtonsoft.Json 12.0.0.0 |
@gdalsnes Thank you for the feedback. We are actively investigating and will get back to you soon. |
@gdalsnes By the statement "This approach doesn't require any custom code or attributes for JSON conversion", document says that if any date is saved in 'UTC date and time ISO 8601' format they can directly be queried using GetCurrentDateTime function and there should not be any conversion needed on JSON properties. The code sample (d1 = DateTime.UtcNow) provided by you shows the correct way to store the date in UTC format which can later be used again the GetCurrentDateTime functions in inline queries, stored procedures or triggers. Similar code snippet is shown in the article as well. Please let me know if this information helps. |
@gdalsnes Please let us know if above details helps. |
@gdalsnes We will now proceed to close this thread because of lack of response. If there are further questions regarding this matter, please comment and we will gladly continue the discussion. |
No, you completely misunderstand my point. |
For lexical order to work (range search) all times must have same format and length. As my example show, the times are shorter if they have seconds resolution. |
So at least with cosmosdb sdk v2 and newtonsoft default datetime format, this does not always produce the recomendee fixed lenght format yyyy-MM-ddTHH:mm:ss.fffffffZ |
It is probably related to this Azure/azure-cosmos-dotnet-v3#1468 Having documentation telling this is a piece of cake and will just work out of the box does not help, as this is almost bloody impossible to get right (I have tried for days, still far from a solution). |
You write:
Most applications can use the default string representation for DateTime for the following reasons:
This approach doesn't require any custom code or attributes for JSON conversion.
Not sure that is true.
Using Netwtonsoft I get different length:
class test
{
DateTime d1;
DateTime d2;
DateTime d3;
}
d1 = DateTime.UtcNow;
d2 = new DateTime(2020, 1, 1, 12, 3, 0, DateTimeKind.Utc);
d3 = DateTime.MinValue.ToUniversalTime();
result of var json = JsonConvert.SerializeObject(t):
"d1": "2020-10-27T12:59:44.9331404Z",
"d2": "2020-01-01T12:03:00Z",
"d3": "0001-01-01T00:00:00Z",
I wish you at least provided example for .NET\C# of how this can work correctly.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: