[fpc-pascal] Implicit conversion problem with TDate type
Michael Van Canneyt
michael at freepascal.org
Wed Nov 2 11:38:41 CET 2016
On Wed, 2 Nov 2016, Gabor Boros wrote:
> Hi All,
>
> I use MWA's IBX for Firebird connection and have problem with date
> parameters. Tony provided to me a test program a suggested write to the FPC
> list. The simple test program is:
>
> program Project1;
>
> uses Variants, Sysutils;
>
> var V: variant;
> D: TDate;
>
> begin
> D := EncodeDate(2016,10,20);
> V := D;
> writeln('date is ',VarType(D));
> end.
>
> The result is: "date is 5" (varDouble)
>
> If modify D: TDate; to D: TDateTime; the result is "date is 7" (varDate)
>
> I (We) missed something or is this a bug?
Only TDateTime is automatically converted correctly to Variant.
TDate and TTime are distinct types and not automatically converted.
They are seen as doubles (the original type of TDateTime).
If Delphi prints another result, then we can look at fixing the implementation.
Michael.
More information about the fpc-pascal
mailing list