我在android中使用date sqlite,希望过滤两个日期之间的日期。我不知道我的问题是什么?它不给错,也不给结果。
我想我在日期和日期函数之间做了一些错误的事情
SELECT * FROM trip_mark WHERE file_type = 2
AND create_time BETWEEN date('2011-11-08 00:00:00') AND date('2011-11-10 00:00:00')
下面是我的桌子结构。我知道表中有日期,我正在使用sqlite浏览器并检查数据库中的数据。
CREATE TABLE `trip_mark` (
`file_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`local_path` varchar(100) DEFAULT NULL ,
`file_type` int(11) DEFAULT NULL,
`import_date` datetime DEFAULT NULL ,
`create_time` datetime DEFAULT NULL ,
`isSyncAvailable` int(11) DEFAULT '1' ,
`syncDate` datetime DEFAULT NULL ,
`isSynced` int(11) DEFAULT '0' ,
`longitude` float DEFAULT NULL ,
`altitude` float DEFAULT NULL ,
`place_logical_name` varchar(150) DEFAULT NULL ,
`file_note` varchar(250) DEFAULT NULL )
这是当前数据表
"1","/sdcard/TripMark_1323375027.jpg","2","2011-11-09 01:10:37","2011-11-09 01:10:37","1","null","0","-1","-1","Unknown Location","");
"2","/sdcard/TripMark_1323375053.jpg","2","2011-02-09 01:11:01","2011-02-09 01:11:01","1","null","0","-1","-1","Unknown Location","");
"3","/sdcard/TripMark_1323375260.jpg","2","2011-11-09 01:14:29","2011-11-09 01:14:29","1","null","0","-1","-1","Unknown Location","sdfas");
我想运行此查询
SELECT * FROM trip_mark WHERE file_type = 2
AND create_time BETWEEN date('2011-11-08 00:00:00') AND date('2011-11-10 00:00:00')
预期的输出数据是
"1","/sdcard/TripMark_1323375027.jpg","2","2011-11-09 01:10:37","2011-11-09 01:10:37","1","null","0","-1","-1","Unknown Location",""
"3","/sdcard/TripMark_1323375260.jpg","2","2011-11-09 01:14:29","2011-11-09 01:14:29","1","null","0","-1","-1","Unknown Location","sdfas"
最佳答案
sqlite没有datetime
,float
,int
,varchar
数据类型。请在此处查看可用类型的列表:
http://www.sqlite.org/datatype3.html
关于android - SQLite查询以获取2个日期之间的数据不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8437323/