在sqlite中尝试将日期格式"2011-03-25 15:00:00.0“转换为"2011-03-25”,遇到了很大的麻烦。
当我运行这一行时,它工作得很好: sqlite> select strftime("%Y-%m-%d",'now');2011-03-16
但是当我运行这一行时,它丢失了: sqlite> select strftime("%Y-%m-%d",'date_start') from test;
我在这方面做错了什么?
萨戈斯
发布于 2011-03-17 03:55:34
从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发布于 2011-03-17 05:27:10
sqlite> select distinct date_start from test;
2011-03-22 08:00:00.0
2011-03-22 09:00:00.0https://stackoverflow.com/questions/5328990
复制相似问题