My Products
Help

MS SQL datetime limitation

by AliMKhan (Updated ‎02-02-2021 13:20 by Yıldırım VISMA )
Our system is using datetime datatype from sql to store date and time information. This type has a precision of 3.33 milliseconds(see Microsoft documentation: https://docs.microsoft.com/en-us/dotnet/api/system.data.sqldbtype?redirectedfrom=MSDN&view=dotnet-pl...). It doesn't offer a 3 digits milliseconds precision.
 
In practice it will accept only the values having the following pattern: ‘yyyy-MM-dd HH:mm:ss.ff0’, ‘yyyy-MM-dd HH:mm:ss.ff3’, ‘yyyy-MM-dd HH:mm:ss.ff7’. Any value not following this pattern will be rounded to the nearest value that can be represented by datetime.
Please be aware of this restriction when sending datetime parameters through API.
This restriction will not cause any issues regarding data integrity. The millisecond precision is important when using ‘LastModifiedDateTime’ parameter for data synchronization. 
 
For example if you request for data changed since ‘2020-07-22T13:47:02.531’ there will be retrieved data changed since ‘2020-07-22T13:47:02.530’. Then you might end up in a situation of getting some data you already have. This data should be treated as changed data by your system which will replace the old one with the new one.
If you request for data changed since ‘2020-07-22T13:47:02.532’ there will be retrieved data changed since ‘2020-07-22T13:47:02.533’. Even though you think you might lose data it will not happen because there is no entry in the database having ‘2020-07-22T13:47:02.532’ as last modified datetime.