Lazarus
Programming => Databases => Topic started by: BlackGrizzly on February 21, 2014, 11:19:52 am
-
Hello! I'm using a TDBGrid with a TSQLite3Dataset and there is a datetime column. Nothing is showed in this column and the other columns of the TDBGrid have
content. Is there a way of show datetime values in TDBGrid column?
If use TSQLite3Connection + TSQLQuery datetime is showed in this column
FPC 2.6.2
Lazarus 1.2RC2
-
how do you have defined datetime column in your sqlite table ?
what values do you have in this column ?
(string: '2014-02-10' or some kind of real values?)
-
datetime column defined in SQLiteStudio as DATETIME
I use ( datetime ( 'now' , 'localtime' ) ) as default value for this column
well then datetime stored as string?
-
You need to read up on SQLite storage classes/data types:
There is no date type - dates are usually represented as strings.
SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:
•TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").
•REAL as Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar.
•INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC.
Applications can chose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions.
The list below shows you all the available storage classes/data types:
NULL. The value is a NULL value.
INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.
REAL. The value is a floating point value, stored as an 8-byte IEEE floating point number.
TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).
BLOB. The value is a blob of data, stored exactly as it was input.
-
datetime column defined in SQLiteStudio as DATETIME
I use ( datetime ( 'now' , 'localtime' ) ) as default value for this column
well then datetime stored as string?
can you post here your SQLite database with one table with one datetime column with values, which are correctly displayed in SQLiteStudio, but not in Lazarus using TSQLite3Dataset
-
Sample application that demonstrates this (uses datetime fields in sqlite, see table tos starttime, finishtime) in bug http://bugs.freepascal.org/view.php?id=26551