I happened to notice that the DateTime library procedure DayOfYear was not always agreeing with the .NET Framework value for DayOfYear, sometimes they would agree and sometimes they wouldn't. On further investigation I found the culprit was the DateDiff procedure, which uses the FPU to subtract one DATETIME (QWORD) from another. It was using the default rounding mode of the FPU. This procedure should not do any rounding, it should truncate. So, I modified the DateDiff procedure to truncate the result. DayOfYear is giving the correct result all the time now.