vendredi 31 juillet 2015

SQLite intermittently querying successfully between two dates

I am doing some select statements to get some data from SQLite databases.

The tables have Start and End dates, the dates are in the format of "31/07/2015 3:00:42 PM". The strange thing is, when I execute the reader, and check it immediately after, the results view will have "{"String was not recognized as a valid DateTime."}"

The thing is that it DID successfully query between the two dates I gave it, even though it apparently doesn't think so.

Now where I became even more confused is when trying to query a second table that also has two Date columns, the query throws the same error, but this time it actually DOESN'T work.

So basically SQLite is querying two tables using a date range, thinks that it failed both times, but actually succeeds on one of the tables.

The queries look like:

SELECT * FROM ShiftDetailLog WHERE StartTime >='31/07/2015 2:00:00 PM' AND StartTime <='31/07/2015 4:00:00 PM' ORDER BY StartTime asc   <<<(This query WORKS)

and

SELECT * FROM DowntimeLog WHERE StartTime >='31/07/2015 1:00:00 PM' AND StartTime <='31/07/2015 4:00:00 PM' ORDER BY StartTime asc    <<<(This query DOES NOT work)

Both StartTime and EndTime are both 'datetime' columns in SQLite in both tables.

Edit: Also, when I try to do something like:

string something = reader[0].ToString();

it actually errors saying "String was not recognized as a valid DateTime"... this is an error thrown by mscorlib...

I'm not referencing a datetime object, or telling it to convert anything to a datetime object...

Aucun commentaire:

Enregistrer un commentaire