Search Object with data range

Hi all,
i want to have an api in my service that return a list of objects created in a time range.
I have create this method in the cloud code js (the model is ‘Objects’):

/**
*

  • @param {DateTime} startDate

  • @param {DateTime} endDate

  • @returns {Promise.<void>}
    */
    getObjectsByRange(startDate, endDate) {

    var whereClause = "created at or after "+startDate + " and created at or before "+endDate;
    var queryBuilder = Backendless.DataQueryBuilder.create().setWhereClause( whereClause );

    var result = Backendless.Data.of( Objects ).find( queryBuilder );

    return result;
    }


but when i tested with “Api Service”, return this error “400 - Invalid where clause (1017)”

What am i doing wrong?

Thank
GF

Hi jempis

What “startDate” and “endDate” are?
Timestamp or String?

Also you can test your query in the Backendless Console

http://support.backendless.com/public/attachments/a56609603ea2dcc22256bb2875b4c875.png&lt;/img&gt;

String! you see capture.png

wrap dates into single quotes

created at or after '01/04/2018 15:50:42' and created at or before '01/05/2018 12:40:33'

now with adding the single quotes response ok, Thank Vladimir

Glad to hear that

You are welcome