1

net.dll for performing operations on sqlite. i am facing issue for sqlite database like i am created column as Text name as DateTime and storing date string into it. i want entries which are in between some date range, but i am not able to execute query.

used query for type of DateTime Column as "Date": **

SELECT * FROM TableName WHERE ColumnName BETWEEN '1800-1-1' AND '2010-12-12'

**

used query for type of DateTime Column as "String":

**

SELECT * FROM MD5_HEADER WHERE Sent BETWEEN '4/1/2007 12:01:00 AM' AND '12/1/2010 4:05:36 AM'

**

if anyone having solution regarding this issue please help me.

(c#, Sqlite.net.dll, framework3.5)

2 Answers 2

1

Try filling the gaps with zeros:

SELECT * FROM TableName WHERE ColumnName BETWEEN '1800-01-01' AND '2010-12-12'
Sign up to request clarification or add additional context in comments.

Comments

0

First, SQLite doesn't have a date type. It stores dates as either text or integer. The first query looks correct assuming your column is of type text since ISO 8061 formatted dates have lexicographical order. It just looks like your missing a semicolon at the end of the statement.

2 Comments

But it checks based on string hence result shows wrong value. and main how to add datetime format in sqlite. (using c#) Because it does not accept dateTime.ToString() as a input for dateTime
Assuming a column type defined as TEXT all you need to do is provide a ISO formatted date string. See stackoverflow.com/questions/114983/…. There's example code in this post stackoverflow.com/questions/8099845/… demonstrating how to insert a row in to a table with a datetime column.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.