Can't Compare Dates Using Sqlite With Ef6
I'm trying to compare dates using Linq to Entities on a SQLite database. The following code works, but I need to trim off the time portion to get the correct results. return (from
Solution 1:
I need to trim off the time portion to get the correct results
No you don't. If you want to include the rows from startDate through endDate inclusive then just use
...&& x.RideDate >= startDate && x.RideDate < endDate.AddDays(1)(Note that the second comparison is now "strictly less than".)
Solution 2:
How are you storing dates on the database ? as unix time integrs ? in that acse you can amend your connection string to include this following config setting and it will make it easy to read the datetime value via EF.
datetimeformat=UnixEpoch;datetimekind=Utc
So something like :
data source="|DataDirectory|\data.sqlite";datetimeformat=UnixEpoch;datetimekind=Utc
Post a Comment for "Can't Compare Dates Using Sqlite With Ef6"