如何选择安卓的SQLite的两个日期范围内的数据 [英] How to select data between two date range in android SQLite
本文介绍了如何选择安卓的SQLite的两个日期范围内的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有表,其中包含与对日期创建的数据。我想选择根据表中的数据,以两个给定日期范围,或一个特定的一个月。
I have table which contains data along with created on date. I want to select data from table according to two given date ranges, or of one particular month.
我不知道该怎么做,作为列上创建的文本类型,并存储为DD-MM-YYYY HH:MM:SS
I am not sure how to do that, as created on column is of type text and is stored as dd-MM-yyyy HH:mm:ss
我使用rawQuery()来获取数据。
I am using rawQuery() to fetch data.
推荐答案
您可以做这样的事情:
mDb.query(MY_TABLE, null, DATE_COL + " BETWEEN ? AND ?", new String[] {
minDate + " 00:00:00", maxDate + " 23:59:59" }, null, null, null, null);
为MinDate
和的maxDate
,这是日期字符串,使你的范围。这个查询会从 MY_TABLE
所有行之间的范围内它下跌。
minDate
and maxDate
, which are date strings, make up your range. This query will get all rows from MY_TABLE
which fall between this range.
这篇关于如何选择安卓的SQLite的两个日期范围内的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文