尝试在sqlite中将日期格式“2011-03-25 15:00:00.0”转换为“2011-03-25”并遇到严重问题。
当我运行此行时,它工作正常: 源码>选择strftime(“%Y-%m-%d”,“now”); 2011-03-16
但是当我跑这条线时,它输了: 源码>从测试中选择strftime(“%Y-%m-%d”,“date_start”);
我在这做错了什么?
Sagos
答案 0 :(得分:0)
从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
答案 1 :(得分:0)
sqlite> select distinct date_start from test;
2011-03-22 08:00:00.0
2011-03-22 09:00:00.0