Microsoft KB Archive/258998

= PRB: DateTime Subtraction May Not Produce an Exact Integer =

Article ID: 258998

Article Last Modified on 4/11/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q258998



SYMPTOMS
When subtracting two DateTimes, the result is a floating point number. As such, the displayed value may not be the exact value. This may lead to further inaccuracies.



CAUSE
Floating point math is frequently inaccurate in any language.



RESOLUTION
When subtracting DateTimes, use ROUND(nDifference, 0) to ensure that you are working with the value you think you are.



Steps to Reproduce Behavior
To observe the problem, run the following code in the Command window: lnDiff = {^2000-03-20 11:31:00} - {^2000-03-20 10:25:00} ? lnDiff                     && 3960 DISPLAY MEMORY LIKE lnDiff   && 3959.99996513 ? INT(lnDiff)                && 3960 ? INT(lnDiff / 60)           && 65 ? INT(ROUND(lnDiff, 0) / 60) && 66

Keywords: kbnofix kbxbase kbprb KB258998

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.