Add to that, the fact that no one is supposed to be over a 100 years old... just shows the stupidity of Borland Staff in using date this way. Not only do I have to correct for the rounding, I also have to correct it for dates earlier than 1899. I have always had functions for floats that I use for dates too... The trick is to get everyone to remember this. MIne are called Is_Zero (Arg) and Are_Equal (Arg1, Arg2).

Kyley Harris wrote:

I wonder if anyone else has noticed this irritating rounding issue on datetimes.

Bear in mind that this is not a useful answer is you care about
historical dates. I only care about dates greater than the year 2000.

Problem. When comparing an "empty date" (meaning Date = 0.0) delphi
behaves differently on different computers meaning that my if
varDateValue = 0.0 can return false a lot of the time. This is also
the same when comparing Dates that have a zero time factor.

on my computer, EncodeDate(1899,12,30) + EncodeTime(0,0,0,0) does not
return 0.0, but something along the lines of zero + an infintesimal
fraction that does not equal zero any more.

I solve my problem with the following method of forcing a date when
setting a date property.

 if DateTimeValue < ZeroDateThreshold /* EncodeDate(1900,1,1) */  then
 begin
   result := 0.0;
 end else
 begin
   result := RecodeMilliSecond(result,0);
 end;

This forces a removal of all these little tiny bits of rubbish on the
end of my datetimes that occurs when I convert my string dates
"yyyymmddhhnnsszzz" into real date etc.

anyone got better ideas? if not.. hope this helps anyone else.



--
Kyley Harris
Harris Software
+64-9-8455274
+64-21-671-821

_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi





_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to