in my database , dates are stored in DD-mm-yyyy format , how can i sort this to obtain the earliest date ?
Cursor c = myDb.query(TABLE, new String[]{"dob"}, null, null, null, null, "dob");
I have selected it to order by dob field but its not ordered …
This is the output for the above query
01-03 17:14:51.595: VERBOSE/ORDER DOB(1431): 01-11-1977
01-03 17:14:51.595: VERBOSE/ORDER DOB(1431): 01-12-1988
01-03 17:14:51.614: VERBOSE/ORDER DOB(1431): 15-01-1977
01-03 17:14:51.656: VERBOSE/ORDER DOB(1431): 31-01-1988
In your case with sqlite and (afaik) it’s lack of a date type, I would store the dates in epoch value in UTC time (this is a good practise anyway since you’ll be timezone-independent) and then you can just sort by lowest value using
ORDER BY.You can just convert back to a readable date in your Java application (use SimpleDateFormat for example)
You’d go about storing the value the other way around (if this is something you need to do)