On 30 Dec 2013, at 1:08am, Fatih BURAL <[email protected]> wrote:
> My name is Fatih, I'm having a trouble about getting data between two
> different dates in SQLite with C# code.
Things that usually trip up people trying that:
* SQLite doesn't have a DATE type. You are actually storing INTEGER REAL or
TEXT and should declare any timedate columns like that.
* If you are doing maths on the dates then you should consider storing them as
numbers, not strings. If instead you are mostly storing the dates and
retrieving them for display then it's probably simpler just to store them as
strings.
* If you are relying on SQLite's functions to process dates in the form
"YYYY-MM-DD HH:MM:SS" then your dates must be in exactly that format. Four
digits for the year, two digits for everything else, with all punctuation in
the right place.
"SELECT * from TABLE t where t.Date1 >= @0 AND t.Date2 <= @1",
date1.ToString("yyyy-MM-dd HH:mm:ss"), date2.ToString("yyyy-MM-dd HH:mm:ss")
Looking at the above, I suspect that your values 't' break one of the above
rules. I assume that "date1" and "date2" are strings in your programming
language and that you've tested that your "ToString" function does have the
results you're expecting.
You might usefully use the shell tool to do something like
SELECT Date1, typeof(Date1), Date2, typeof(Date2) FROM t
and check to see that your date fields do have dates at least ten characters
long with "-" signs in the right place.
Another way to look at the problem is just to forget that it concerns dates at
all. You're comparing three strings and your code should work for any strings
in alphabetic order.
Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users