Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DateTime Calculation Problems
Message
From
19/03/1999 03:04:41
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00199527
Message ID:
00199641
Views:
18
>I've noticed that Calculations involving DateTime Values combined with INT, MOD or / sometimes act strangely
>
>For Example:
>
>I've observed the following:
>
>X = {04/22/1999 16:00:00} - {04/22/1999 15:00:00})
>?INT(X/60)
>
>X = ROUND({04/22/1999 16:00:00} - {04/22/1999 15:00:00}, 2)
>?INT(X/60)
>
>
>The First result yields the incorrect number of 59
>
>The Second pass yields a correct number of 60.
>
>
>I suspect that the problem has to do with how VFP internally handles precision as regards to datetime calculations.
>
>Marshal Rosenberg
>Marshal_Rosenberg@Compuserve.Com
Yes, Datetime is a real value expressed as Date + (seconds/86400) in calculations. So division precision affects the result.
X = {04/22/1999 16:00:00} - {04/22/1999 15:00:00}
? x*1.0000000  && Would give 3599.999999
? int(x*1.00) && Would give 3599
? int(int(x)/60) && Would give 60
? int(int(x*1.00)/60) && Would give 59
X = int({04/22/1999 16:00:00} - {04/22/1999 15:00:00})
? int(x/60) && Would give 60
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform