Android : SQLite - Order by next upcoming Date (ignore year)

on Friday, October 10, 2014


I have a table of persons, and I want to order them by the next upcoming birthday (ignoring year). I've used the method described in this answer:


http://stackoverflow.com/a/20522025/2934340


OR


SQL-code:



SELECT *
FROM _table
ORDER BY SUBSTR(DATE('NOW'), 6)>SUBSTR(birthdate, 6), SUBSTR(birthdate, 6);


The problem is that I use another date format. In the answer above the date format is mm-dd, I want to use dd-mm. Now my dates sort like this:



17-10-1974
03-10-1979
29-02-1980
20-10-1993


I want it to sort like this:



17-10-1974
20-10-1993
29-02-1980
03-10-1979 (Because we are at 10-10-2014/past this date)


What changes can I do to my code do achieve this?


0 comments:

Post a Comment