I have a SQLITE DB with a string field which contains a date in the following format: \"01.01.2012\". What I want is to sort the by this string formatted date in a query. I trie
The values in the startdatum
column are not in a format that SQLite recognizes, so you cannot use it as a parameter to strftime
.
(Even if it worked, the result would not be sorted correctly because that date format does not begin with the most significant field, the year.)
You could try to extract the date fields so that the sorting is equivalent with the yyyy-mm-dd
order:
SELECT ...
ORDER BY substr(startdatum, 7, 4),
substr(startdatum, 4, 2),
substr(startdatum, 1, 2)
But I would recommend to convert the values into a supported format in the first place.