© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•10mo ago•
13 replies
Stefanidze

✅ DateTime rounding struggles

While writing tests for my api, I've noticed an interesting issue.
My assertion comparing an object returned by an api with a reference in the database kept failing, while they were querying the same object in the database.

The difference was apparently a microsecond property of
DateTime
DateTime
that did not make it through Json serialization, while EF core returned the full value, thus the objects were different.

Is there a way i could modify serialization properties in asp.net api to transmit the full timestamp without sacrificing data integrity? Or somehow round value to disregard the millisecond property?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Rounding? (Urgent) [Answered]
C#CC# / help
4y ago
❔ DateTime?
C#CC# / help
3y ago
❔ problem datetime
C#CC# / help
4y ago
help datetime
C#CC# / help
4y ago