[Gambas-user] CFloat() and CDate()
Benoit Minisini
benoit.minisini at gambas-basic.org
Wed Nov 9 19:43:42 CET 2022
Le 09/11/2022 à 18:43, Hans Lehmann a écrit :
> Hello,
>
> why do the following two lines
>
> (1) Print CFloat(Date("01/01/-4801 01:00:00"))
> (2) Print CFloat(Date("01/01/-4801 00:00:00"))
>
> the *same* real number 0.958333333333333
>
Because Date() returns the date part without the time part (and converts
your string into a Date with CDate automatically).
> and
>
> Print CDate(0.95833333333)
>
> 23:00:00
>
> ?
Because Date() is for localized dates, which are a string converted
automatically with CDate() is not.
As soon as you mix date functions using localization and date functions
not using localization without knowing exactly what you are doing, you
get problems.
In that specific case, your date is '31/12/-4802 23:00:00 GMT', and as
the minimum date is -4801, you get a time only.
Regards,
--
Benoît Minisini.
More information about the User
mailing list