如何使用日期字段筛选ActiveAndroid Delete语句

时间:2013-07-25 11:24:25

标签: android android-sqlite activeandroid

我尝试从有一个日期字段的表中删除(表示为字符串)。 我想通过以下声明来做到这一点:

Object result=new Delete().from(Information.class).where("Date>=?", date.replace(".","-")).execute();

似乎没有删除任何内容,结果变量为null。

我有两个问题:

  1. 如何获取已删除对象的数量?

  2. 如何使用带日期变量的位置?

2 个答案:

答案 0 :(得分:1)

问题出在对象方,而不是ActiveAndroid / SQLite方面。 SQLite可以使用日期进行比较,但源日期必须是LocalDateTime。正如您所看到的,我一直在使用字符串,因此比较结果为假。

答案 1 :(得分:0)

您是否必须将(')字符添加到日期?

Object result=new Delete().from(Information.class).where("Date>='?" + "'", date.replace(".","-") ).execute();

喜欢那个?