Recent

Author Topic: At DBGrid cast the max(aDate) expression  (Read 669 times)

dsyrios

  • Jr. Member
  • **
  • Posts: 55
At DBGrid cast the max(aDate) expression
« on: December 31, 2018, 12:00:35 pm »
Hi,
how can I display in a DBGrid field  (using sqlite3) a sql expression e.g. MAX(aDate) in right date display format?
I used at an old project the sql 'SELECT MAX(aDate) FROM Table1'
without problem until Laz v.1.6.4 , as I remember.
I noticed that from Laz v.1.8.2 and then, fields with MAX() data are display as (MEMO).
I seems that max() is been FieldTYpe: ftMemo and trying to CAST it, it becomes ftLargeint
How can I solve it?  I tried to find a solution but I failed.
Thanks in advance.
I attach a simple example.
Laz 1.8.4/FPC 3.0.4/ win7/32
Laz 2.0.0/FPC 3.0.4/ mint-mate 19.1

dsiders

  • Full Member
  • ***
  • Posts: 208
Re: At DBGrid cast the max(aDate) expression
« Reply #1 on: December 31, 2018, 01:39:06 pm »
how can I display in a DBGrid field  (using sqlite3) a sql expression e.g. MAX(aDate) in right date display format?
I used at an old project the sql 'SELECT MAX(aDate) FROM Table1' without problem until Laz v.1.6.4 , as I remember.
I noticed that from Laz v.1.8.2 and then, fields with MAX() data are display as (MEMO).
I seems that max() is been FieldTYpe: ftMemo and trying to CAST it, it becomes ftLargeint
How can I solve it?  I tried to find a solution but I failed.

https://www.sqlite.org/datatype3.html

Quote
2.2. Date and Time Datatype

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.

https://www.sqlite.org/lang_datefunc.html
Lazarus 2.0.2 / FPC 3.0.4 / Windows 8.1 64-bit