我使用此查询在我的数据库中创建一个事务表:
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
我需要Query才能执行操作..需要立即协助。
答案 0 :(得分:1)
你可以试试这个。
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格式。