jeudi 18 février 2016

select rows by datetime in sqlite

I am trying to select rows which are inbetween a startdate and an enddate in c# with sqlite.

my dates are formatted like this:

2015-05-16T17:22:04.920+02:00

which should be a valid format for sqlite (ref: http://ift.tt/1mOgs1D)

i am trying to select the row like this:

string CmdString = "SELECT * FROM " + tablename +  "WHERE DATETIME(timekey) >= DATETIME('2015-05-16T17:22:04.920+02:00') AND DATETIME(timekey) <= DATETIME('2015-05-16T17:24:04.920+02:00')";
SQLiteCommand cmd = new SQLiteCommand(CmdString, con);
SQLiteDataAdapter sda = new SQLiteDataAdapter(cmd);
DataTable MatchDt = new DataTable();

sda.Fill(MatchDt);

The Error i get is:

SQLiteException: SQL logic error or missing database

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire