How to retrieve data sorted by createdAt ?

I would like to retrieve data sorted by createdAt but i have no idea how ==

Here’s the API to request sorting by the “createdAt” column. I assume it is your column, because the one created by Backendless is called “created”:

    BackendlessDataQuery query = new BackendlessDataQuery();
    QueryOptions queryOptions = new QueryOptions();
    queryOptions.addSortByOption( "createdAt" );
    query.setQueryOptions( queryOptions );

Am i doing it correct in swift ?

<ol>queryOptions.sortBy(["created'])</ol>

Yes, it is correct if you would like to use only “created”

I would like to ask ask that can it sort by ascending or descending , thanks

I would like to also ask that if sort can be ascending or descending , thanks

Descending sort order can be requested with:

queryOptions.sortBy(["created DESC'])

Otherwise, ascending order is applied by default.

ok thanks , sorry to bother you but i have another question is that can i query where date is before some date ?

Please see this guide.

Am i doing it correct ?

created before ‘2016-03-08 10:40:56 +0000’

i am using created before and here my query "created before ‘03-08-2016 18:40:56 GMTGMT+8’ AND (user.objectId = ‘40A4BF71-947D-E5BC-FFA5-B12FACE78D00’ OR user.objectId = ‘5A69E14B-D73C-1626-FF9C-8F715F539C00’) " It should be 10 but it giving me 11

it should have before but it is giving me all before plus the item created at this date 03-08-2016 18:40:56 GMTGMT+8’ and make it 11 items

Is there some error since before and at or before return the same thing

“GMTGMT” in your query does not look quite right.

Can you check my another question about the date , thanks .

This one?

Am i doing it correct ?
created before '2016-03-08 10:40:56 +0000'

Hello guys
can i do this
List<String> sortBy = new ArrayList<String>();
sortBy.add( “date_sortir_exp ASC” ); // sorting by a date o
queryOptions.setSortBy(sortBy );

Yes, you definitely can.

I want to retrieve data with whereclause and sort by created

BackendlessDataQuery query = new BackendlessDataQuery(); 
QueryOptions queryOptions = new QueryOptions(); 
queryOptions.addSortByOption( "created" ); 
query.setQueryOptions( queryOptions ); 
query.setWhereClause("user_name = "+userName); 
 




Backendless.Data.of( Question.class ).find(query, new AsyncCallback&lt;List&lt;Question&gt;>() 

but method Backendless.Data.of( Question.class ).find required DataQueryBuilder not BackendlessDataQuery

How can I do that

Looks like you are using version 4 of the SDK, but are applying the 3.x API.

What version of the backend do you have? 3.x or 4.0? It will appear in Backendless console right next to the Backendless logo.

So I can do that with this code

DataQueryBuilder queryBuilder = DataQueryBuilder.create(); 
queryBuilder.setWhereClause("user_name = '"+userName+"'" ); 
queryBuilder.setSortBy("created ASC"); 
Backendless.Data.of( Question.class ).find(queryBuilder, 
 new AsyncCallback&lt;List&lt;Question&gt;>() { 
 @Override 
 public void handleResponse(List&lt;Question&gt; response) { 
 
 } 
 
 @Override 
 public void handleFault(BackendlessFault fault) { 
 
 } 
 });