Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG: int() returning wrong values from datetime operatio
Message
From
13/10/2005 11:01:09
 
 
To
13/10/2005 10:01:54
Arlei Silva
Chevron Oronite Brasil Ltda.
Capuava, Brazil
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Miscellaneous
Thread ID:
01058678
Message ID:
01058705
Views:
10
>Hi all
>
>I have tried it with VFP 6, 7, 8 and 9. All versions returning the same result. Copy and Paste the following code on a new program window and then execute it.
>
>Anyone know what is happening? Or maybe this is just a bug?
>Thank you all
>
>
>
>set date british
>clear
>
>*****************************
>* Sets start and end datetime
>*****************************
>m.T_START = ctot("08/01/2005" + " " + "05:15")
>m.T_END = ctot("08/01/2005" + " " + "05:20")
>
>*****************************************
>* Find and show the difference in seconds
>*****************************************
>m.DIFF_SECONDS = m.T_END - m.T_START
>? m.DIFF_SECONDS					&& Prints 300
>
>*****************************************
>* Find and show the difference in minutes
>*****************************************
>m.DIFF_MINUTES = (m.DIFF_SECONDS / 60)
>? m.DIFF_MINUTES					&& Prints 5,0000
>
>**********************************************************
>* Now the weird thing. Shows the integer of m.DIFF_SECONDS
>**********************************************************
>? int(m.DIFF_MINUTES)					&& Prints 4 (Should be 5, not 4!!!)
>
the datetime on VFP is unusable to make algebra,
because the internal VFP C++ conversion routine is wrong.
clear

T_START = {^2005/01/08 05:15:00}

T_END   = {^2005/01/08 05:15:01}

DIFF_SECONDS = m.T_END - m.T_START
? m.DIFF_SECONDS*1.00000000000000000		&& don't Print 1

T_START1 = T_START

* INCREMENT T_START 10 days

FOR K=1 TO 864000
	T_START1 = T_START1 + 1  && 1 seconds
NEXT
DIFF_SECONDS1 = m.T_START1 - m.T_START
? ROUND(m.DIFF_SECONDS1,0)                  && Print 863995, you have lost 5 seconds!
Previous
Reply
Map
View

Click here to load this message in the networking platform