Convert date function to sqlite

Trying to convert the date format "2011-03-25 15: 00: 00.0" to "2011-03-25" in sqlite and get deep problems.

When I run this line, it works fine: sqlite> select strftime ("% Y-% m-% d", 'now'); 2011-03-16

But when I run this line, it loses: sqlite> select strftime ("% Y-% m-% d", "date_start") from the test;

What am I doing wrong in this?

Sagos

0
sqlite objective-c iphone sqlite3
source share
2 answers

Remove quotes from date_start

 ~ e$ sqlite3 SQLite version 3.7.5 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table test (dt); sqlite> insert into test values (22222222); sqlite> select strftime("%Y-%m-%d",dt) from test; 5613-14-26 sqlite> insert into test values (2222222); sqlite> select strftime("%Y-%m-%d",dt) from test; 5613-14-26 1372-02-19 sqlite> sqlite> select substr('2011-03-22 08:00:00.0',1,19); 2011-03-22 08:00:00 sqlite> insert into test values ('2011-03-22 08:00:00.0'); sqlite> select strftime("%Y-%m-%d",substr(dt,1,19)) from test; 5613-14-26 1372-02-19 2011-03-22 
0
source share
 sqlite> select distinct date_start from test; 2011-03-22 08:00:00.0 2011-03-22 09:00:00.0 
0
source share

All Articles