3

The comparison of time values does not work if you compare the time value before writing to the database with the time value that was written to the database.

The cause of the problem is that in BC DateTime and Time values are rounded by SQL Server ([See MS Docs](https://learn.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-ver16)). This means that a DateTime / Time value can change just because it was written to the database, the comparison with the original value then runs on error.


For DateTimes there is a method "CompareDateTime" in the codeunit TypeHelper to compare DateTimes with a small threshold value to compensate for the rounding of the DateTime values. However, the threshold seems to be unnecessarily large.

Also, there is no method to compare Times.


See https://github.com/microsoft/BusinessCentralApps/issues/483


New methods for comparing DateTime and Time values should therefore be created.

Category: Development
STATUS DETAILS
New

Comments

J

See https://github.com/microsoft/BCApps/issues/335#issuecomment-1832028924 - due to an upcoming platform fix, new methods become obsolete.

Category: Development