Skip to content Skip to sidebar Skip to footer

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=&quot;|DataDirectory|\data.sqlite&quot;;datetimeformat=UnixEpoch;datetimekind=Utc

Ref: https://stackoverflow.com/a/24323591/3660930

Post a Comment for "Can't Compare Dates Using Sqlite With Ef6"