Sharanabasu Angadi Sharanabasu Angadi - 1 year ago 285
Android Question

Convert string to date in SQLITE

I can convert

date format to string of any format using strtime function

select strftime('%Y-%d-%m-%Y', '2012-09-13 12:44:22');

but I have String which is in
format, How can I convert to
format in
so that I can use that in date comparison.

Answer Source

Use something like this:

select datetime(substr(col, 7, 4) || '-' || substr(col, 4, 2) || '-' || substr(col, 1, 2)) from table;

where col is the column of table having the date in yyyy-MM-dd format

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download