Reputation: 589
In my sqlite database there is a "Date" field, & its data type is varchar,
I want to get all data between two dates - how would I do this from a sqlite database?
Upvotes: 1
Views: 5207
Reputation: 853
The best solution is here: Working with strings in SQLite.
Upvotes: 0
Reputation: 3907
Try this
NSString * sql = [[NSString alloc] initWithFormat:@"SELECT * FROM table WHERE (startdate <='%@') AND (enddate >='%@)",startdateString, enddateString];
OR
SELECT * FROM table WHERE datecol BETWEEN '2012-02-08 00:00:00' AND '2012-01-10 00:00:00'
Upvotes: 2
Reputation: 3927
Use one of the above function to convert your string to date More detail please refer: http://www.sqlite.org/lang_datefunc.html
Upvotes: 0