怪异的sqlite3日期格式
感觉sqlite3的日期格式很怪异,所以用sqliteman建了一个测试表,代码如下:createtable'test'('dt'date);deletefromtest...
感觉sqlite3的日期格式很怪异,所以用sqliteman建了一个测试表,代码如下:
create table 'test' ('dt' date);
delete from test;
insert into test values ('2012-03-01');
insert into test values ('2012-01-01');
insert into test values ('2012-06-01');
select * from test where dt between '2012-02-01' and '2012-03-31';
-- 返回‘2012-03-01’是正确的结果;
select * from test where dt between '2012-2-01' and '2012-03-31';
-- 返回空集;
select * from test where dt between '2012-02-01' and '2012-03-31';
-- 返回'2012-06-01'和'2012-03-01‘显然多返回了一条;
请问这些应该如何解释?是否sqlite的日期格式只接受"YYYY-MM-DD“的类型,否则就会出现不正常的结果? 展开
create table 'test' ('dt' date);
delete from test;
insert into test values ('2012-03-01');
insert into test values ('2012-01-01');
insert into test values ('2012-06-01');
select * from test where dt between '2012-02-01' and '2012-03-31';
-- 返回‘2012-03-01’是正确的结果;
select * from test where dt between '2012-2-01' and '2012-03-31';
-- 返回空集;
select * from test where dt between '2012-02-01' and '2012-03-31';
-- 返回'2012-06-01'和'2012-03-01‘显然多返回了一条;
请问这些应该如何解释?是否sqlite的日期格式只接受"YYYY-MM-DD“的类型,否则就会出现不正常的结果? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |