Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Query Collection by Month

I have looked at the docs about date queries, but I cannot see if we can spilt the string, within the query, so it gives me results based on a month ?

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

Query Collection by Month

Hi,

Here is an example of query by day: https://getsatisfaction.com/apperyio/...

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Query Collection by Month

Thank you, but that does not answer my question. I cannot query any month based on that, without a complex query on a WHERE statement ?

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

Query Collection by Month

Addy,

You will need it. Let's try. Write a query based on this example. If this doesn't work just post your code here and we'll help.

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Query Collection by Month

Here is the code, no errors, but I get no results either:

precode
where:{"sid":6, "_createdAt" : {"$gt" : "2014-02-01 00:00:00.000" , "$lt" : "2014-02-28 00:00:00.000"}}
/code/pre

The above is the output, of what the URL is sending. Its giving me no errors.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Query Collection by Month

Hi Addy - try to describe all JSON object values with quotes:
pre
where:{"sid":"6", "_createdAt" : {"$gt" : "2014-02-01 00:00:00.000" , "$lt" : "2014-02-28 00:00:00.000"}}
/pre

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Query Collection by Month

no, you mean JSON.stringify ?

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Query Collection by Month

This is the code output:

precode
where:{"$and" : [{"sid":6}, {"_createdAt" : {"$gt" : "2014-02-01 00:00:00.000" , "$lt" : "2014-02-28 00:00:00.000"}}]}
/code/pre

And this is how I get it:

precode
var querydate;
var date = new Date(),
y = date.getFullYear(),
m = date.getMonth(),
firstDay = new Date(y, m, 1),
lastDay = new Date(y, m + 1, 0),
querydate = '"_createdAt" : {"$gt" : "' +
myFormat(firstDay) + '" , "$lt" : "' +
myFormat(lastDay) + '"}';

$.ajax({
type: 'GET',
beforeSend: function(request) {
request&#46;setRequestHeader('X-Appery-Database-Id', '<db_ID>');
},
url: 'https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/collections/questions',
dataType: 'json',
data: {
where: '{"$and" : [{"sid":'+sid+'}, {'+querydate+'}]}'
},
success: function(res) {
$('#source_monthlyQcount_box')&#46;text(res[0]&#46;count);
}
});

/code/pre

It looks fine to me, but i get no results, and no errors?

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

Query Collection by Month

Any ideas why its not bring any data ?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Query Collection by Month

Hello, sorry, but this needs additional time, we'll get back as soon as possible.

Return to “Issues”