Question

I try to delete from a table where there is a date field (represented as a string). I'd like to do it by the following statement:

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

It seems that nothing was deleted, the result variable is null.

I have 2 questions:

  1. How can I get the number of the deleted objects?

  2. How can I use a where with a date variable?

Was it helpful?

Solution

The problem was on the object side, not the ActiveAndroid/SQLite side. SQLite can use dates for comparison but the source date has to be LocalDateTime. As you can see, I've been using Strings so the comparison gave false results.

OTHER TIPS

Dont you have to add the (') char to a date?

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

Like that?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top