Retrieve data between two dates in Android SQLite
android
Solution
Put literals
public void history(String startdate,String enddate) {
Cursor mCursor = db.rawQuery("SELECT * FROM "+ KK_AIRLINEBOOK +
" WHERE " + KEY_Bookingdate +
" BETWEEN '" + startdate + "' AND '" + enddate + "'", null);
}
However it is better if you use selectionArgs
public void history(String startdate,String enddate) {
Cursor mCursor = db.rawQuery("SELECT * FROM "+ KK_AIRLINEBOOK +
" WHERE " + KEY_Bookingdate +
" BETWEEN ? AND ?", new String[]{startdate, enddate});
}
Problem
I want to retrieve data between two dates in Android `SQLite` I used one function in `SQLiteAdapter` class. My function is ``` public void history(String startdate,String enddate) { Cursor mCursor = db.rawQuery("SELECT * FROM "+ KK_AIRLINEBOOK + " WHERE " + KEY_Bookingdate + " BETWEEN " + startdate + " AND " + enddate , null); } ``` However it doesn't work it shows syntax error near `AND`