Cannot save SQLITE DATETIME fields using UNIDAC - 0.0 is not a valid timestamp

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dpadureanu
Posts: 2
Joined: Mon 07 Mar 2022 16:15

Cannot save SQLITE DATETIME fields using UNIDAC - 0.0 is not a valid timestamp

Post by dpadureanu » Mon 07 Mar 2022 16:37

Hi,
We use latest 9.1 UNIDAC components.
When trying to store a Delphi TDateTIme field inside SQLITE using UNIDAC we receive error "0.0 is not a valid timestamp".
We use code like this

Code: Select all

dbSource.StartTransaction;
          qGetLicenses.Insert;
          ....
          qGetLicenses.FieldByName('ACQUISITION_CONTRACT_DATE').AsDateTime := tbMemLicenteDisponibile.FieldByName('ACQUISITION_CONTRACT_DATE').AsDateTime;
          .....
          qGetLicenses.Post
dbSource.Commit;          
At the DateTime field it raises the error.

Please help us to understand how UNIDAC handles TDateTime fields under SQLITE.
Until now we used FireDac and we didn't encountered any problem with TDateTime fields formatting on SQLite.

We found the 2 params
workDatabase.SpecificOptions.Values['DateFormat'] := 'YYYY.MM.DD';
workDatabase.SpecificOptions.Values['TimeFormat'] := 'HH:MM:SS';

but when we used like here the date is always 0.
Please help!

frickler
Posts: 37
Joined: Wed 04 Apr 2018 08:30

Re: Cannot save SQLITE DATETIME fields using UNIDAC - 0.0 is not a valid timestamp

Post by frickler » Tue 08 Mar 2022 08:28

Problem is: SQLite doesn't really have a DATETIME field type. One must either use TEXT or REAL. In the source code of "LiteClassesUni.pas" you'll see that dtDateTime and dtSQLTimeStamp are internally mapped to SQLite's TEXT field type. The two parameters you mentioned should match the actually used format of dates und times in the database. Use a third party tool like the free "SQLite expert" to look, which format is actually used.

dpadureanu
Posts: 2
Joined: Mon 07 Mar 2022 16:15

Re: Cannot save SQLITE DATETIME fields using UNIDAC - 0.0 is not a valid timestamp

Post by dpadureanu » Tue 08 Mar 2022 13:24

OK, this I know, but why UNIDAC doesn't recognize by himself the formatting string when assigning TDateTime fields, and raises an format error at fields values assignment? It happens only for Delphi TimeStamp Fields. TDatetime fields that does not include time works OK.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Cannot save SQLITE DATETIME fields using UNIDAC - 0.0 is not a valid timestamp

Post by MaximG » Fri 01 Apr 2022 12:03

Thank you for the information. Please send us a sample project where the issue can be reproduced, including the DDL script for creating database objects used in the project. For your convenience, please use the e-support form https://www.devart.com/company/contactform.html

Post Reply