I can not filter by end date on an SQLite.
For this I have created a method which is passed 2 dates, one start and one end.
private void consultListaDietas (Date di, Date df) {
SQLiteDatabase db =conn.getReadableDatabase();
Dieta dieta=null;
Date date = new Date();
Cursor cursor = db.rawQuery("SELECT * FROM "+Utilidades.TABLA_DIETAS,null);
if (di==null && df==null){
while (cursor.moveToNext()){
dieta = new Dieta();
dieta.setId_Dieta(cursor.getInt(0));
dieta.setNoches(cursor.getInt(1));
dieta.setKm(cursor.getDouble(2));
String fecha = cursor.getString(3)
DateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
date = iso8601Format.parse(fecha);
} catch (ParseException e) {
Log.e(TAG, "Parsing ISO8601 datetime failed", e);
}
dieta.setFecha(date);
dieta.setId_Usuario_FK(cursor.getInt(4));
dieta.setId_Proyecto_FK(cursor.getInt(5));
}
}else{
cursor=null;
Date[] args = new Date[]{di,df};
cursor = db.rawQuery("SELECT * FROM "+Utilidades.TABLA_DIETAS + " WHERE BETWEEN di AND df",args);
}
}
I have the problem in the else, in the args I get an error "Wrong 2nd argument type". I have verified that both the argument di and df are Date arguments. I guess I have a problem in my practice.
Thanks in advance !!