gpt4 book ai didi

Android SQLITE 查询获取特定范围内的日期值

转载 作者:行者123 更新时间:2023-11-30 02:17:53 24 4
gpt4 key购买 nike

我使用此查询在我的数据库中创建事务表:

String CREATE_TRANSITION_TABLE1 = "CREATE TABLE "
+ TABLE_TRANSITION_TWO + "(" + KEY_TRASITIONID
+ " INTEGER PRIMARY KEY," + KEY_AMOUNT_CREDIT + " DOUBLE,"
+ KEY_AMOUNT_DEBIT + " DOUBLE," + KEY_PURPOSE + " TEXT,"
+ KEY_PURPOSE1 + " TEXT," + KEY_PURPOSE2 + " TEXT," + KEY_DATE
+ " DATE," + KEY_BALANCE + " DOUBLE" + ")";

这个查询从表中获取所有事务:

String selectQuery = "SELECT  * FROM " + TABLE_TRANSITION_ONE;

现在我想在 Date 的特定范围内过滤结果。喜欢:

StartDate : 2/1/2015 
EndDate : 6/1/2015

我需要查询来执行操作。需要即时帮助。

最佳答案

你可以试试这个。

SELECT * From  TABLE_NAME WHERE date_column BETWEEN  '"+StartDate+"' AND '"+EndDate+"';

完整查询:

"SELECT * FROM " + TABLE_TRANSITION_ONE + " where " + KEY_DATE + " BETWEEN '2015-02-05' AND '2015-02-15';

这里的StartDate和EndDate是字符串变量。

但对于此操作,您的日期应采用 YYYY-MM-DD 格式。

关于Android SQLITE 查询获取特定范围内的日期值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29001595/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com