mercredi 4 mai 2016

Android SQLite RawQuery not returning records with 2017 date

I have a database that contains upcoming births. The file has 5 records in it with due dates of (11-15-2016,10-15-2016, 12-14-2016, 12-13-2016 and 02-12-2017) The query is

SQLiteDatabase db = dbhelper.getReadableDatabase();
        String QueryPart1="SELECT inseminations._ID, inseminations.patient_id, inseminations.date_due ";
        String QueryPart2="FROM inseminations ";
        String QueryPart3="WHERE inseminations.date_due>=? ";
        String QueryPart4="ORDER BY inseminations.date_due ASC";
        String FinalQuery=QueryPart1+QueryPart2+QueryPart3+QueryPart4;
        mCursor = db.rawQuery(FinalQuery ,howToFilter);'

howToFilter is

            String howToFilter[]={ExpectedDateDue};

ExpectedDateDue is

        ExpectedDateDue = new SimpleDateFormat("MM-dd-yyyy").format(new Date());

The query retrieves all records except for the one from 2017, the listview is sorted correctly, it's as if the query is only taking those records where the month is after the current month instead of the entire date.

Aucun commentaire:

Enregistrer un commentaire