[yunqa.de] Re: Rounding of REAL and DISQLite3Api.DateTimeToJulianDate

  • From: Edwin Yip <edwin.yip@xxxxxxxxxxxxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Wed, 25 Feb 2009 22:46:43 +0800

Thank you Ralf,
But when the program gets the TDateTime values the precision is not only 4
digits, but I can only use ROUND(X, 4) to compare the values after saving
into the database in the way described in my original email...

Best Regards,
Edwin Yip

Mind Mapping is as Effortless as Typing
http://www.InnovationGear.com


On Wed, Feb 25, 2009 at 9:41 PM, Delphi Inspiration <delphi@xxxxxxxx> wrote:

> Edwin Yip wrote:
>
> >It seems that rounding with precision 4 is not OK, for example SQL:
> >SELECT datetime(2454888.2673), datetime(2454888.2674),
> datetime(2454888.2675)
> >
> >returns:
> >18:24:54, 18:25:03 and 18:25:12 respectively in the time part, so
> precision 4 is not precise enough. what do you think caused this on the data
> in my database? thank you.
>
> The rounding precision depends on the precision you need. Sine you are
> dealing with datetime values here, hours, minutes, and seconds are
> represented as fractions. The number of seconds per day is 24 * 60 * 60 =
> 86400. So the minimum fraction for one second is 1.15740740740741e-5 =
> 0.0000115740740740741. This should explain why your Julian day value needs
> at least 5 digits to represent a time value to represent down to the second
> representation.
>
> Example:
>
>  SELECT
>    strftime ('%S', 0.00001),
>    strftime ('%S', 0.00002),
>    strftime ('%S', 0.00003),
>    strftime ('%S', 0.00004)
>
> Ralf
>
> _______________________________________________
> Delphi Inspiration mailing list
> yunqa@xxxxxxxxxxxxx
> //www.freelists.org/list/yunqa
>
>
>
>

Other related posts: