empty (not null!)I want to create sql statement as this:
SELECT * FROM table WHERE date BETWEEN ? AND ? ORDER BY date ASC LIMIT 1
I have a sql in database as this^
Cursor cursor = context.getContentResolver().query(
URI,
new String[] { col_id, col_2,DATE },
DATE + " BETWEEN ? AND ?" ,
new String[] {dateAsString, stopDate)} ,
DATE + " ASC LIMIT 1");
cursor = database.query(
table, projection,
selection, selectionArgs,
null, null, sortOrder);
Sql is passed by cursor is null. I copy database to sd card and see it via SQLiteManager plugin to FF -0 all data exists and the statement above works in console, so something wring with my sql statement.
Could you tell me wat’s wrong wtih that?
UPDATE extend question
I store some data which has column Date that saved as:
- 2012-11-30 09:12:29.392 which pattern yyyy-MM-dd HH:mm:s.S
- Convert this to long and save it to TEXT type of columns in my table
- So I got something like that 1354197364633
I want to get row which date in databse beetween two values:
database.rawQuery("SELECT * FROM Track WHERE Date BETWEEN ? AND ?", selectionArgs);
But I don’t succeeded in it. Now I know that is doesn’t work at any database but doesn’t got a solution. Could you suggest the way how I can resolve my issue?
I try to use the solution below. So in cursor I get this query:
SQLiteQuery: SELECT * FROM Track WHERE Date BETWEEN CAST(? AS INT) AND CAST(? AS INT)
with this parameters in mBindArgs:
{1=1354248261841, 2=1354262663195}
I check the date value in track, it lays beyween them, but cursor still returned empty.
The cause is issue in logic of my app: in some frame between requests to database this rows have been updated so I haven’t got my date.