Hi
Today we ran into a very strange issue in Ax 2009 when looking up records like this:
select Table1
where Table1.createdDateTime == Table2.createdDateTime
A record that had the exact same CreatedDateTime was never returned. After analyzing the table I noticed that out of 400.000 records, 145 records looked like this in the CreatedDateTime field:
2012-04-12 11:48:49.003
Since there were 3 milliseconds added to the value the query did not return the records. It took a while to understand this, since milliseconds are not presented in the table browser. They can only be seen in the query window of the SQL Server Management Studio.
After analyzing the table in the database I did find the reason, but not a solution for this.
The default value for CreatedDateTime field looks like this in the database:
dateadd(millisecond, -datepart(millisecond,getutcdate()),getutcdate())
This is how AX creates the fields.
What this default value is supposed to do is to return current date but strip the milliseconds.
The problem with this is that getutcdate() gets called twice. That means that there is a slight possibility for the method to return two different values, especially if there is a high load on the database. Also, SQL Server has a precision of 3 milliseconds, so milliseconds will be rounded to 3.
So, what happened in the 145 records of my table is this:
2012-05-30 11:20:30.567 - .564 = 2012-05-30 11:20:30.003
That is the reason. Now - does anyone have a solution?
/Jonas
*This post is locked for comments