samedi 11 avril 2015

how to find records between two string dates SQLITE - Android


String start = "9-4-2015";
String end = "11-4-2015";
SimpleDateFormat sdf = new SimpleDateFormat("d-M-yyyy");
List<IncomeModel> allToDos = db.getAllIncomesWeeks();

for (IncomeModel todo : allToDos) {
DatabaseDate = todo.getDate();
try {
if (sdf.parse(start).before(sdf.parse(end))) {
incomeModel.add(todo);
sum = sum + Integer.parseInt(todo.getAmount());
}
} catch (NumberFormatException | ParseException e) {
e.printStackTrace();
}
}
tvSum.setText(sum + "");


I needs a records between start date and end dates. I also Tried This Query


"SELECT * FROM expenses WHERE date BETWEEN '"+ start + "' AND '" + end + "'"


But It's Also Shows Wrong Data.


Aucun commentaire:

Enregistrer un commentaire