Query a date range.

This forum contains topics that were moved from Get Satisfaction
Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Query a date range.

Post by Robert Larsen »

I am wanting to build a selectable query for date range. Example Two calenders... First calender you select the from date, and the second calender you select the to date. Then you click search and it returns all items from a collection that was created in between those two dates. Second problem I know you have to specify a where perimeter but how would you achieve this using the calender widget, if at all possible?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Query a date range.

Post by Kateryna Grynko »

Hi Robert,

Add the following code to a service parameter 'where':prevar d1 = Apperyio("mobiledatepicker_1").datapickerRoot.find("input").val();
var d2 = Apperyio("mobiledatepicker_2").datapickerRoot.find("input").val();
return jQuery.parseJSON('{"mydate":{"$gte":"'+ d1+'", "$lt":"'+ d2 +'"}}');/preWhere mobiledatepicker_1 and mobiledatepicker_2 are Datepicker names,
mydate is a name of Database date field.

A result of execution is a list of objects where
mobiledatepicker_1 < mobiledatepicker_2.

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Query a date range.

Post by Robert Larsen »

So would I add two Datepicker widgets and have it set to store the selected date to local storage using the names mobiledatepicker_1 and mobiledatepicker_2? And also could you clarify or explain more of what you mean by the "mydate is a name of Database date field"? DO you mean I would insert the column name for the date field of the collection here? I am not a 100% what you mean by this.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Query a date range.

Post by Kateryna Grynko »

Hi Robert,

mobiledatepicker_1 and mobiledatepicker_2 are names of components to chose date:
http://devcenter.appery.io/documentat...

mydate is a name of field in Database that is of a 'date' type:
http://devcenter.appery.io/documentat...

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Query a date range.

Post by Robert Larsen »

Ok this is not working for me server response is just incorrect query no other details. I added the provided code to the request tab of where under add js. Then I added two mobiledatepicker components to the page and named them accordingly. I then changed "mydate" to RODate in the java field. Set the service to invoke on button click. I even changed the date format of the mobiledatepicker to yyyy-mm-dd. What am I doing wrong here.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Query a date range.

Post by Kateryna Grynko »

Hi Robert,

Could you please share the app and tell us how to invoke this service?

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Query a date range.

Post by Robert Larsen »

The app is shared it's called tech time.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Query a date range.

Post by Kateryna Grynko »

Hi Robert,

In service Test tab, an empty list is returned from Database Time%20Records, too. Please save values there first.

Could you please specify what dates are to choose and how to reproduce the issue?

You use a field "mydate" in where query. Please make sure there is a such field in your collection. We cannot find it in Create service parameters.

Mike6979865
Posts: 0
Joined: Fri Jul 11, 2014 3:53 pm

Query a date range.

Post by Mike6979865 »

Hi, I tried this code provided above to query a date range, but it's not working.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Query a date range.

Post by Kateryna Grynko »

Hi Mike,

Could you please clarify whether there is an error in browser console or you receive an empty response?

Post Reply