I stumbled onto this problem yesterday when I was busy writing some unit tests using SQLLite. My environment is Windows7/Delphi XE.
Using TADOQuery in conjunction wi
I had the same problem with VFPOLEDB (the Visual FoxPro driver) but the trick with adDBTimeStamp
didn't work. FWIW, that's VFPOLEDB 9.0.0.5815 with Delphi 7 and also with RAD Studio 10 (Seattle).
In the case of VFPOLEDB there is another possible workaround that is based on the fact that in Fox the underlying representation for date/time values (type 'T') is the same as that of the date values (type 'D') passed by OLEDB, i.e. a 64-bit double where the integer part represents days since January 1st in the year 0001 and the fractional part represents the time of day.
If the table field has type 'T' and OLEDB passes a date then Fox coerces the value by doing nothing at all. So all that's needed here is adding back in the fractional part.
Example, with start_time
being a date/time field:
cmd.CommandText := 'insert into foo (start_time) values (:start_time)';
cmd.Parameters.ParamByName('start_time') := Now;
cmd.Execute;
This gives 2016-05-22 00:00:00
in the table.
Now, add the fractional part like this:
cmd.CommandText := 'insert into foo (start_time) values (:start_time + :fraction)';
t := Now;
cmd.Parameters.ParamByName('start_time') := t;
cmd.Parameters.ParamByName('fraction') := Frac(t);
cmd.Execute;
This gives 2016-05-22 02:17:42
. Even fractional seconds get preserved, although they do not get displayed.