I have a field (named as time, but type is TEXT) in my Sqlite Database. In current format of that column is YYYY:MM:DD_HH:MM (as 2011:11:01_11:30 ). Now I have to sort this column, so I think I have to do two things:
- Convert string value to date.
- Then sort with column.
Then how can I convert that column into DateTime? Or is there any other way to do this?
To convert String into Date, In my case this works fine,
EDIT:
1.2 Date and Time Datatype
SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:
Applications can chose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions.
So, just use as a INTEGER or TEXT and use ORDER BY clause for sorting.