Roberto Padovani
2007-12-02 11:21:16 UTC
Hi all!
two things: 1) a (possible) improvement to sqlite3ds; 2) the old
problem with dates and time
1) I found a sqlite database that uses the TIMESTAMP data type, but
this is not directly supported by the Tsqlite3Dataset written by Luiz.
I added the if-else checks in sqlite3ds.pas for this type, which
refers to ftTimestamp of TFieldType in db.pas. And I also added
db.DefaultFieldClasses[ftTimeStamp] := TDateTimeField at run-time,
because in db.pas it is defined as nil (and I didn't want to recompile
it).
So, now my app can understand a timestamp field as a TDateTime instead
of a string...
2)and here comes the problem! The code:
var d: TDateTime;
..
d := database.FieldByName('birthday').asDateTime;
...
will always store the zero date: 30 Dec 1899
why ?
Being urgent, at the moment I am reading the dates as strings by using
the "date" or "datetime" function of SQLite in the query, i.e.:
SELECT date(birthday) AS string_birthday FROM people;
and then parsing them with the powerful functions in the freepascal
RTL, but I would like to understand this once for all.
Can anyone help ?
Thanks !!
R#
two things: 1) a (possible) improvement to sqlite3ds; 2) the old
problem with dates and time
1) I found a sqlite database that uses the TIMESTAMP data type, but
this is not directly supported by the Tsqlite3Dataset written by Luiz.
I added the if-else checks in sqlite3ds.pas for this type, which
refers to ftTimestamp of TFieldType in db.pas. And I also added
db.DefaultFieldClasses[ftTimeStamp] := TDateTimeField at run-time,
because in db.pas it is defined as nil (and I didn't want to recompile
it).
So, now my app can understand a timestamp field as a TDateTime instead
of a string...
2)and here comes the problem! The code:
var d: TDateTime;
..
d := database.FieldByName('birthday').asDateTime;
...
will always store the zero date: 30 Dec 1899
why ?
Being urgent, at the moment I am reading the dates as strings by using
the "date" or "datetime" function of SQLite in the query, i.e.:
SELECT date(birthday) AS string_birthday FROM people;
and then parsing them with the powerful functions in the freepascal
RTL, but I would like to understand this once for all.
Can anyone help ?
Thanks !!
R#