mehdi
(Mehdi)
December 20, 2016, 10:10pm
1
Hello,
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();
c.add(Calendar.DATE,1);
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();
queryOptions.addRelated("position");
dataQuery.setQueryOptions(queryOptions);
dataQuery.setWhereClause(query);
dataQuery.setPageSize(100);
Backendless.Persistence.of(Disparues.class).find(dataQuery, new AsyncCallback<BackendlessCollection<Disparues>>() {
@Override
public void handleResponse(BackendlessCollection<Disparues> response) {
Log.i("good", String.valueOf(response.getData().size()));
}
@Override
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 !
What is the data type of the “Description” column?
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.
mehdi
(Mehdi)
December 20, 2016, 10:58pm
5
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 +"'" ;
dataQuery.setWhereClause(query);
Backendless API return me the data of dateIncription column and if I switch Description with dateIncription like that:
String query = "dateInscription after '"+ variable +"'" ;
dataQuery.setWhereClause(query);
Backendless API return me the data of Description column.
How I can fix that ? Thank you !
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…
mehdi
(Mehdi)
December 20, 2016, 11:19pm
7
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:
https://backendless.com/feature-14-sql-based-search-for-data-objects-using-console/
mehdi
(Mehdi)
December 20, 2016, 11:57pm
9
Thank you for this feature ! It’s so cool to test my where clause ! 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 ?
mark-piller
(Mark Piller)
December 21, 2016, 12:07am
10
Try the following:
dateInscription after ‘12-22-2016’
If it does not work, let me know your application ID.
mehdi
(Mehdi)
December 21, 2016, 12:16am
11
I have test (you can see in screenshot) but is the same problem.
My application ID is : 7D977595-D4F6-6595-FF7A-9BBC7AB88B00
Thank you !
mark-piller
(Mark Piller)
December 21, 2016, 12:30am
12
I just tried the same query in your app and it works just fine:
http://support.backendless.com/public/attachments/d33d60322de6b52ac49336abc743561b.png</img> ;
Try deleting local storage for develop.backendless.com , then clear cache and reload the console. It should work.
mehdi
(Mehdi)
December 21, 2016, 12:59am
13
Ohh ! Thank you so much Mark Piller ! You have fix my problem You are Amazing !
Thank your for taking the time to fix my problem
I use backendless API since a month and I love that ! Keep going like that !
Mehdi, from Paris !