Subject | Re: [IBO] Time Clock |
---|---|
Author | Helen Borrie |
Post date | 2009-05-28T02:14:33Z |
At 11:19 AM 28/05/2009, you wrote:
Delphi's DateTime values are floats which, as you know, never exist as exact numbers. When Delphi casts them to integer, you literally get the integer part of the float. Rewrite your functions so that you end up with a float that you can apply your own rounding rules to.
Better still, do the intervals calculation in your SQL. For the interval between two time-part values, it returns an exact number of seconds as DECIMAL(9,4). Bring the results into your application AsCurrency.
Helen
>Ive got 2 fields, both of type TimeCasting rules for float to integer.
>
>Now, I get these value.. respectivly
>
>Time1:=TempQuery2.FieldbyName('Visit1_Time_In').AsDateTime; (val is
>Time is 7:00 am)
>Time2:=TempQuery2.FieldbyName('Visit1_Time_Out').AsDateTime; (val is
>Time is 7:05 am)
>
>Now, I was using a function
>
>HowmanyMinutes:=MinutesBetween(Time2,Time1);
>
>It returned a value of 4 minutes. Weird.
>
>So Then I did
>
>HowManySeconds := SecondsBetween(Time2,Time1);
>
>And found that it returned 299 seconds (Should be 300)
>
>Any ideas why? The value appears right in the database, but its a second off
>when doing the math.
Delphi's DateTime values are floats which, as you know, never exist as exact numbers. When Delphi casts them to integer, you literally get the integer part of the float. Rewrite your functions so that you end up with a float that you can apply your own rounding rules to.
Better still, do the intervals calculation in your SQL. For the interval between two time-part values, it returns an exact number of seconds as DECIMAL(9,4). Bring the results into your application AsCurrency.
Helen