我是 Android 开发新手,所以我使用 ActiveAndroid 来管理数据库,但在使用带有日期变量的查询时遇到问题,我有这个:
From fromQuery = new Select().from(Shift.class);
//It doesn't matter what currentShiftDates do.
CurrentShiftDates currentShiftDates = new CurrentShiftDates();
fromQuery = fromQuery.where("startDate > ? and startDate < ?",currentShiftDates.startDate,
currentShiftDates.endDate);
return fromQuery.execute();
我读到查询需要将参数作为长值传递,所以我尝试使用 .getTime():
fromQuery = fromQuery.where("startDate > ? and startDate < ?",currentShiftDates.startDate.getTime(), currentShiftDates.endDate.getTime());
但是还是不行。
我做错了什么?
最佳答案
非常抱歉,它不起作用,因为我正在编写“startDate”并且列名称是“StartDate”,所以正确的查询是:
fromQuery = fromQuery.where("StartDate > ? and StartDate < ?",currentShiftDates.startDate.getTime(), currentShiftDates.endDate.getTime());
关于java - 使用 ActiveAndroid 的带有 DATE 变量的 Where 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27283314/