jeudi 29 janvier 2015

Sorting by date from bad string field in SQLite?

I'm using an SQLite database in an app I'm developing with ionic, but unfortunately the database is built in such a way that the date fields are strings, not proper Date type values. (I'm not the person who's responsible for building this database, nor can I ask them to fix this). They all follow a "DD-Mon" format.


So the structure is as follows



id |date | (other columns...)
1 |"25-Jan"|
2 |"25-Jan"|
3 |"30-Jan"|
4 |"30-Jan"|
5 |"31-Jan"|
6 |"31-Jan"|
7 |"31-Jan"|
8 |"31-Jan"|
# (500 more rows like this)


The problem is that I want to use a query that only gets the dates from a certain day onwards (something like SELECT * FROM table WHERE /*(date after X)*/;)


One thing to notice that might be helpful, although I still couldn't think of a solution, is that the IDs go from early to late, so if a given id X is greater than an id Y, then date X comes after date Y.


Aucun commentaire:

Enregistrer un commentaire