I have a database where I have a table:
我想要获取 11 月至 11 月的所有值。
我创建了类似的东西:
public static List<Plan> getPlanListByMonth(SQLiteDatabase db, DateTime date) {
String where = "strftime('%m', '"+"date"+"') = " +
"'"+"11"+"'";
Cursor cursor = db.query(TABLE_NAME, null, where,
null, null, null, null, null);
return getPlanList(cursor);
}
private static List<Plan> getPlanList(Cursor cursor) {
List<Plan> PlanList = null;
if (cursor != null) {
PlanList = new ArrayList<>();
if(cursor.moveToFirst()) {
do {
Object obj = getPlan(cursor);
PlanList.add((Plan) obj);
} while (cursor.moveToNext());
}
cursor.close();
}
return PlanList;
}
但没有效果。知道如何按月获取所有值吗?
Oh well.
将您的查询更改为阅读
SELECT * FROM workoutPlan WHERE strftime('%m', date) = '11'
or
SELECT * FROM workoutPlan WHERE CAST((strftime('%m', date)) AS INTEGER) = 11
就这样。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)