如何选择安卓的SQLite的两个日期范围内的数据范围内、如何选择、两个、日期

2023-09-07 08:34:24 作者:格子间女人

我有表,其中包含与对日期创建的数据。我想选择根据表中的数据,以两个给定日期范围,或一个特定的一个月。

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.

 
精彩推荐
图片推荐