Date query with whereclause

I’m trying to send a query with .whereclause( “Description after ‘MM/dd/yyy HH:mm:ss’” ) but i have not a good results.
My code:

Calendar c = Calendar.getInstance();

SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");

String variable = format1.format(c.getTime());

String query = "Description after '"+ variable +"'" ;
BackendlessDataQuery dataQuery = new BackendlessDataQuery();
QueryOptions queryOptions = new QueryOptions();

Backendless.Persistence.of(Disparues.class).find(dataQuery, new AsyncCallback<BackendlessCollection<Disparues>>() {
 public void handleResponse(BackendlessCollection<Disparues> response) {
 Log.i("good", String.valueOf(response.getData().size()));
 public void handleFault(BackendlessFault fault) {
 Log.i("error", fault.toString());

Results :

I/good: 0

My table :
file: topic.PNG

Why the size is 0 ?Someone know where the problem from ? Thank you ! :slight_smile:

What is the data type of the “Description” column?

The data type is STRING

So here’s what’s going on: you’re applying the “after” operator to a String value:

String query = “Description after '”+ variable +"’" ;

That does not make sense, because “after” applies only to the DATETIME columns.

I found my problem, I have set DATATIME for data type of Description, thank you !
But I don’t know how I can fix that :

When I check my colonne Description with

String query = "Description after '"+ variable +"'" ;

Backendless API return me the data of dateIncription column and if I switch Description with dateIncription like that:

String query = "dateInscription after '"+ variable +"'" ;

Backendless API return me the data of Description column.

How I can fix that ? Thank you ! :slight_smile:

PS: You can see my table in the file tablebackend.PNG

When your query includes a condition for the “Description” column, Backendless will return all objects satisfying the condition. Likewise, if your condition checks the “dateIncription” column, Backendless will find all the objects matching the condition.

I am not sure what exactly you want to fix there…

Yes, I’m okay with that but if I send this query:

String query = "dateInscription after '2016-12-22'" ;

In my column I have just one object, but backendless check the dates of Description column because it return me 3 results :

12/26/2016 00:00:00
01/27/2017 00:00:00
12/30/2016 00:00:00

I would like just one result because my condition is for “dataIncription” column and not for “Description” column.
It must return me all objects satisfying the condition and here there is just the object where the date is after ‘2016-12-22’, no ? I have just one object in ‘dateInscription’ column.

Ps: I am sorry if I express myself badly.

Your screenshot shows only partial data, I do not see how many total objects you have in the table, so it is hard for me to say. Btw, use this feature to test your where clause conditions:

Thank you for this feature ! It’s so cool to test my where clause :slight_smile: ! But I see the same problem.
Now you can see in screenshot my problem, the query it’s about dateInscription but I have nothing who satisfying the condition in “dataInscription” column.

I think it do the query with “Description” column ? Why ?

Try the following:

dateInscription after ‘12-22-2016’

If it does not work, let me know your application ID.

I have test (you can see in screenshot) but is the same problem.
My application ID is : 7D977595-D4F6-6595-FF7A-9BBC7AB88B00

Thank you !

I just tried the same query in your app and it works just fine:</img>

Try deleting local storage for, then clear cache and reload the console. It should work.

Ohh ! Thank you so much Mark Piller ! You have fix my problem :slight_smile: You are Amazing !
Thank your for taking the time to fix my problem :slight_smile:

I use backendless API since a month and I love that ! Keep going like that !

Mehdi, from Paris ! :slight_smile: