我是Android开发人员的新手,所以我使用ActiveAndroid来管理数据库,而我在使用带有Date变量的查询时遇到了麻烦,我有:
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();
我已经读过查询需要将参数作为long值传递,所以我尝试使用.getTime():
fromQuery = fromQuery.where("startDate > ? and startDate < ?",currentShiftDates.startDate.getTime(), currentShiftDates.endDate.getTime());
但它仍然无法正常工作。
我做错了什么?
答案 0 :(得分:7)
我&#39;非常抱歉,它没有工作,因为我正在写&#34; startDate&#34;列名是&#34; StartDate&#34;,所以正确的查询是:
fromQuery = fromQuery.where("StartDate > ? and StartDate < ?",currentShiftDates.startDate.getTime(), currentShiftDates.endDate.getTime());