I have a sqlite database which has table of tasks which has a column of dueDates. I want to filter out the dates greater than tomorrow's date.
So if tomorrow's date is 29 th april I should get the dates later than tomorrow. I want to get the number of tasks later than tomorrow.
For this I have converted string into date. The format is :
    Calendar calendar = Calendar.getInstance();
dateToday  = calendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("d MMM yyyy");
 dueDateToday = df.format(dateToday);
calendar.add(Calendar.DAY_OF_YEAR, 1);
 dueTomorrow = calendar.getTime();
 dueDateTomorrow = df.format(dueTomorrow);
and the query is:
     public int getPendingTasksLaterDays(String tomorrow) {
    ArrayList<Task> conList = new ArrayList<Task>();
    String selectQuery = "SELECT * FROM " + TASK_TABLE + " WHERE " + KEY_TASK_STATUS + " = 1" + " AND " +
            KEY_DUE_DATE + " > '" + tomorrow + "'" ;
    SQLiteDatabase db = this.getWritableDatabase();
    Cursor mCount= db.rawQuery(selectQuery,null);
    if (mCount.moveToFirst()) {
        do {
            count = mCount.getInt(0);
        } while (mCount.moveToNext());
    }
    Log.d("query",selectQuery);
    Log.d("count",String.valueOf(count));
    mCount.close();
    return count;
}
But the query is not working may be.. The count I am getting is 0. What's going wrong? Thank you..
Aucun commentaire:
Enregistrer un commentaire