I can't find a solution for my problem.
I have an HTML5 Web SQL Database with a table like this:
db.transaction(function(tx) {
tx.executeSql("CREATE TABLE IF NOT EXISTS todo " +
"(todoId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
"note VARCHAR(100) NOT NULL, " +
"state VARCHAR(100) NOT NULL, " +
"todoDate DATETIME NOT NULL)");
});
When I add values to this database (notation = dd-MM-yyyy), it looks like the todoDate is added as a string to the database. When I collect and sort some todoDate values from the database with the following query, the values are sorted in the wrong order:
sql = "select * FROM todo order by todoDate asc";
Output:
todoId - note - state - todoDate
3 - blabla - someinfo - 01-01-2013
1 - blabla - someinfo - 22-09-2012
2 - blabla - someinfo - 25-10-2012
I would like to get the following order:
todoId - note - state - todoDate
1 - blabla - someinfo - 22-09-2012
2 - blabla - someinfo - 25-10-2012
3 - blabla - someinfo - 01-01-2013
How can I achieve this?
I found the function str_to_date but it doesn't work or I did something wrong.
Thanks in advance!