android - SQLite - Order by next upcoming Date (ignore year) -
I have a table of individuals, and I want to order them by the next upcoming birthday (ignoring the year). I have used the method described in this answer:
OR
SQL-code:
Proper order from SUBSTR (DATE ('now') from SELECT *, 6) & gt; SUBSTR (birthday, 6), SUBSTR (birth date, 6); The problem is that I use any other date format. Date format is mm-DD in the answer above, I want to use DD-MM. Now my dates are like this:
17-10-1974 03-10- 1979 29-02-1980 20-10-1993 I want to sort it in such a way:
17-10-1974 20 -10-1993 29-02-1980 03-10-1979 (Because we are 10-10-2014 / last of this date) What changes can I make in my code, What does this achieve?
An easy way to store it, will be the month and day switching with the SUBSTR () function: SELECT * from SUBSTR's order (DATE ('now'), 6) & gt; (SUBSTR (birthdays, 4, 3) || SUBSTR (birth date, 1, 2)), (SUBSTR (birthday, 4, 3) || SUBSTR (birth date, 1, 2));
Comments
Post a Comment