Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Increment time() by 1 minute
Message
De
10/06/2005 09:44:15
 
 
À
09/06/2005 19:36:47
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01020951
Message ID:
01022124
Vues:
13
>>OK for your records it stores it with milliseconds. It seemingly doesn't provide access to it but for any queries depending on datetime value you should be prepared for that. Otherwise you get empty resulset where you expected some records to return. IOW:
>>
>>select * from myTable where myDatetime = m.ltTime
>>
>>is dangerous. Here is a simple reproducing code:
>>
>>
>>Create cursor test (myTime t)
>>For ix=0 to 23
>>	Insert into test values (Datetime(2000,1,1,m.ix))
>>	ltCheck = Ctot('^2000/1/1 '+Padl(m.ix,2,'0'))
>>	If (m.ltCheck - test.myTime <> 0)
>>	? 'Mismatch',m.ix
>>	endif
>>EndFor
>>
>
>This is interesting. I've known about this issue since VFP5.0, and I thought it was fixed, but it seems I was running the wrong tests. I usually tried to store datetime to a variable, and then store it into a datetime field, and see if there's a difference. This part still works - these seem to be rounded to seconds.
>
>But running your example, even with
>
ltCheck=Datetime(2000,1,1,m.ix)
>i.e. having the check variable assigned the same value as the one inserted into the cursor, gives me 0.0010058283810 seconds difference each time, on certain values of ix. Which is really weird. One would expect that the datetime() function would yield a round number of seconds, but it doesn't:
>
>
t=datetime()
>insert into test values (t)
>?(t-mytime)*1.00000000000000   && displays zero
>t=ctot(ttoc(t))    && this should force it to discard milliseconds if it had them
>?(t-mytime)*1.00000000000000   && displays 0.0010058283810 again
>
>Internally, the time part of the datetime is just an 32 bit integer. So there's obviously something in the way this integer is stored into a datetime variable, that makes it behave like a badly rounded float.
>
>Still somewhat buggy, I agree.

Hi Drahan,

datetime computation uses floating point, no integer.

Every field to/from variable conversion
make a 1/86400 operation, this add a error to the value.
But this show that the datetime field is not deterministic, too;
do a read/write loop change the field value!
CLEAR
mm = 0
ss = 15

create cursor test (myTime t)
FOR hh=0 TO 23
	varTime = Datetime(2000,1,1,m.hh,m.mm,m.ss)
	Insert into test values (m.varTime)
	tDiff = NULL
	? "H M S",m.hh,m.mm,m.ss
	FOR k=1 TO 10
		IF test.myTime - m.varTime = m.tDiff
			EXIT
		ENDIF
		tDiff  = test.myTime - m.varTime
		If m.tDiff <> 0
			? "difference", m.tDiff*1.0000000
		ENDIF
		ZZ=test.myTimE	         && convert to float variable format
		REPLACE myTime WITH M.ZZ && reconvert to field format
	ENDFOR
NEXT
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform