Page 1 of 2
Where Date is greater than today
Posted: Thu Mar 20, 2014 12:09 pm
by Caleb Kirby
I'm trying to build into my query to only return events greater than today's date. Obviously today is dynamic
If I hard code the date it works
{"Event_date":{"$gt":'2014-03-20'}}
but I don't know how to get it to work dynamically
this does not work
{"Event_date":{"$gt":$.datepicker("setDate", "0")}}
Where Date is greater than today
Posted: Thu Mar 20, 2014 1:03 pm
by Nikita
Where Date is greater than today
Posted: Thu Mar 20, 2014 10:14 pm
by Caleb Kirby
Hi Nikita,
I tried with the below in the 'where' part of the query but had no luck
var d = new Date();
d.setDate(d.getDate() + 0);
var dateStr = d.toISOString();
return '{"EventStartDate":{"$gte":"'+ dateStr +'"}}';
I'm not sure if I'm even headed in the right direction here and would appreciate some more assistance.
thanks
Where Date is greater than today
Posted: Fri Mar 21, 2014 2:22 am
by Igor
Hi,
Lets see if this code help:
pre
code
var d = new Date();
d.setDate(d.getDate());
var dateStr = d.toISOString();
return '{"_createdAt":{"$gte":{"$date":"'+ dateStr +'"}}}';
/code
/pre
You can check service request/response is correct in browser console network tab.
Where Date is greater than today
Posted: Fri Mar 21, 2014 4:34 am
by Igor
Could you post app publick link?
Where Date is greater than today
Posted: Fri Mar 21, 2014 4:36 am
by Caleb Kirby
Where Date is greater than today
Posted: Fri Mar 21, 2014 4:40 am
by Igor
Could you also tell us the steps how to reproduce this?
Where Date is greater than today
Posted: Fri Mar 21, 2014 4:45 am
by Caleb Kirby
Sorry, from landing screen - upcoming events - search with QLD as the selected option. It should then give back a list and exclude any before today
Where Date is greater than today
Posted: Fri Mar 21, 2014 5:47 am
by Igor
Where did you add this code?
You should add it on your datasource-request tab-where clause-add JS.
http://docs.appery.io/documentation/r...
Where Date is greater than today
Posted: Fri Mar 21, 2014 6:00 am
by Caleb Kirby
Sorry I had added it into the wrong place.
i have placed it there now and this is the message under the console
Failed to load resource: the server responded with a status of 400 (Bad Request) https://api.appery.io/rest/1/db/colle...