Sqlite does not have a datetime data type.
Sqlite has only 4 types:
- integer number
- floating point number
- (saved as utf-8 or utf-16 and automatically converted)
- blob
In addition, sqlite is typical for display, which means that any column can contain a value of any type. The declared type is used for only two things:
- the inserted values ββare converted to the specified type if they seem convertible (and this does not seem to apply to the values ββassociated with
sqlite_bind_*
methods in general) - it somehow hints at an indexer or optimizer (I just know that it has problems using indexes when a column is not typed)
Moreover, sqlite will silently perceive something as a type. He will interpret it as an integer type if it starts with "int", as a string, if it contains "char" or "text", as a floating point number, if it is "real", "double" or "number" and like a blob if it's a "blob". In other cases, the column is simply untyped, which is not a problem for sqlite, given how little typing is.
This means that "1/1/2011" is just a string and neither dates in the format "mm / dd / yyyy" nor dates in the format "dd / mm / yyyy" are sorted by date when sorting by ascetic (actually definitely).
If you saved the dates in ISO format ('yyyy-mm-dd'), asciibetical sort will be compatible with date sorting and you will have no problem.
source share