This project has moved and is read-only. For the latest updates, please go here.


SQLite datetime issue


Trying to open Top 200 Rows I got FormatException: String was not recognized as valid DateTime at ErikEJ.SqlCeToolbox.ToolWindows.ResultesetGrid.LoadData(String sqlText)

The connection string has DateTime Kind=Utc option. (The ServerVersion is

did a more experiments with it. SQLiteStudio showed the raw values - it seems to be stored in unix format and somehow wrongly (I can’t figure why it is caused by infrastructure - I am using SQlite-net, SqLitePCL.raw dlls got through Nuget as the infrastructure, SQLiteConnection is constructed with storeDateTimeAsTicks = true as default setting.) . (e.g. stored 622159416000000000 value is interpreted as 18.7.1972 22:00:00 by the infrastructure).

Then I experimented with SQLiteStudio, to figure out the SQLite Toolbox is able to show date time stored as correct unix format. I cloned the original table structure to a different table, then insert one row through SQL INSERT statement and using function strftime('%s', 'now'.) Then using function Datetime(MyDateTypeColumn, 'unixepoch') in SQL SELECT statement showed it correctly. And of course the SQLiteStudio showed the value in raw format in the grid – an integer number (even for the original case, which was quite valuable for me).
I looked at SQLite Toolbox, Edit top 200 Rows, View Data as Report, Script as SELECT execution all raised the exception. Only using replacing MyDateTypeColumn Datetime (MyDateTypeColumn, 'unixepoch') in , Script as SELECT was successful.

Question (or kind of suggestion)from that all: What do you think, if the SQLite Toolbox, Edit top 200 Rows, View Data as Report, Script as SELECT execution shows raw values in grid for Datetime SQLite type by default (not doing any date time conversion) , like SQLiteStudio seems to do? (Or if have some setting which kind of implicit date time conversion is used for that with possibility of no conversion?)
I tried to use SQLite very recently, so I might miss something important. Then please excuse me if the suggestion sounds stupid to you.

file attachments

Closed Dec 5, 2015 at 1:16 PM by ErikEJ
Moved to github


Mojmir wrote Oct 3, 2015 at 5:34 AM

Additional info to question about connection string:
The database was originally created with DateTimeKind=Utc option.
Because some problems with original provider libraries, I changed the provider to SQlite-net-pcl (
Now I see the provider does not allow open db file with a custom connection string. So there is simply called SQLiteConnection ctor with database file path argument. (trying to put there connection string failed on runtime)
To the question, not I haven’t tried setting DataTimeFormat to UnixEpoch in the connection string so far. (To do it I should probably change the SQLite provider lib? Any advice?)

It all happened on education kind of work, so I can share it (in the attachment)

ErikEJ wrote Oct 3, 2015 at 10:41 AM

I am using the System.Data.SQLite provider - It looks to me like the data in that column does not allow itself to be converted to datetime

wrote Nov 5, 2015 at 3:08 PM

wrote Dec 5, 2015 at 1:16 PM