Hello,
I have a collection of events and event start dates.
Is is possible to only request events that are occurring within the next 7 days?
I would imagine the app would need to figure out what day it is currently.
Thanks for your help!
Hello,
I have a collection of events and event start dates.
Is is possible to only request events that are occurring within the next 7 days?
I would imagine the app would need to figure out what day it is currently.
Thanks for your help!
Hello! Please check this post https://getsatisfaction.com/apperyio/.... You just need to filter using your field with Date type, not the _createdAt field as suggested in that post.
Hi Marina,
This is what I have so far for a where parameter on the page loading with the goal of listing events that are 7 days in the future from the current date. Its not working but maybe you can spot something i'm missing?
Thanks!
var d = new Date();
d.setDate(d.getDate() + 7);
var dateStr = d.toISOString();
return '{"EventStartDate":{"$gte":{"$date":"' + dateStr + '"}}}'
Take what's inside the return and run in the database console (open Query section). Do you get any data there?
I get an incorrect query
Hi,
Please try query string without "$date".
pre
code
{"EventStartDate":{"$lte":"+ dateStr +"}}
/code
/pre
You should first use simple query to ensure that everything works
pre
code
{"EventStartDate":{"$lte":"2013-08-24T20:42:05.465Z"}}
/code
/pre
Hi Igor,
This simple query works:
{"EventStartDate":{"$lte":"2013-08-24T20:42:05.465Z"}}
but trying the query string with $date doesn't work.
This is what i have in "where" on page load.
var d = new Date();
d.setDate(d.getDate() + 7);
var dateStr = d.toISOString();
return '{"EventStartDate":{"$lte":" + dateStr + "}}'
sorry, i meant trying the query string without $date...
Hi Chris,
It seems that in your "return" string some issue with quotation marks. Please copy/paste below code, I've tested this code, it works.
precode
var d = new Date();
d.setDate(d.getDate() + 7);
var dateStr = d.toISOString();
return '{"EventStartDate":{"$lte":"'+ dateStr +'"}}';
/code/pre
Hey Igor,
It works! that great to see..
So i have a select menu with 3 options and their values:
Today: 0
Tomorrow: 1
Next 7 Days: 7
im storing the local variable as eventdaterange and im trying this code with no luck
var d = new Date();
d.setDate(d.getDate() + "' + localStorage.getItem("eventdaterange") + '");
var dateStr = d.toISOString();
return '{"EventStartDate":{"$lte":"'+ dateStr +'"}}';
Appreciate your help. I'm new to programming so its nice to see it coming together with your help.
Thanks