Support Topics Documentation Slack YouTube Blog

GeoPoints metadata dates question

Hello,

I have imported the following data into GeoPoints:
41.7870431,-88.19962129999999,“locations”,“isStore=true|isEvent=false|start=1569942543000|end=1633286950000|name=Store#101”
41.9878565,-88.0518365,“locations”,“isStore=true|isEvent=false|start=1569942543000|end=1633286950000|name=Store#201”
32.8916766,-96.9477532,“locations”,“isStore=true|isEvent=false|start=1569942543000|end=1633286950000|name=Store#301”
41.8403395,-87.6137011,“locations”,“isStore=false|isEvent=true|start=1569942543000|end=1569946143000|name=EventOld”
41.8403395,-87.6137011,“locations”,“isStore=false|isEvent=true|start=1570064400000|end=1572483600000|name=EventCurrent”
41.8403395,-87.6137011,“locations”,“isStore=false|isEvent=true|start=1572570000000|end=1572656400000|name=EventFuture”

I read that the start and end dates have to be in Unix Timestamp format milliseconds. I have the following code to try to make sure the current date / time is between the metadata start and end:

const searchPoints = (latitude, longitude) => {
//console.log(‘searchPoints’);
//console.log('latitude: ’ + latitude);
//console.log('longitude: ’ + longitude);
const query = new Backendless.GeoQuery();
query.latitude = latitude;
query.longitude = longitude;
query.categories = [‘locations’];
query.includeMetadata = true;
query.radius = ‘6000d’;
query.units = Backendless.Geo.UNITS.MILES;
var now = new Date().getTime() / 1000;
query.condition = “start < " + now + " and " + now + " < end”;
//console.log(query);

return Backendless.Geo.find(query);

}

But I get no results back. What do I need to change?

Hello,

I guess the issue is here, try to replace the line with the next one

var now = Date.now();

Regards, Vlad

That fixed it! Thanks

Btw, you can test your “query.condition” in Dev Console