Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query a date range.

Hi Mike,

It seems you have wrong "date" field type.

You should have "Date" type.

See details: http://prntscr.com/4y6bzd/direct

If you have here "string" you can not sort this value as date.

After you will get in your "date" response field something like this: http://prntscr.com/4y6cww/direct

Regards.

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

Query a date range.

The problem is I already have alot of data... How do I change the column from String to Date. I'm not able to edit and I have hundreds of records...

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

Query a date range.

Can I use _CreatedAt instead? I tried it,and it didn't work.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query a date range.

Hi Mike,

You can not edit existent column type.

But it's easy to delete current column and create new column with type you need.

Yes you can use "createdAt" field as well as "updatedAt" field.

But here is some difference.

Base query string is:

pre

{"_createdAt": {$gt: {"$date": "2011-04-15T00:32:22.883Z"} } }

/pre

So code should be:

pre

var d1 = new Date(Apperyio("startDate").datapickerRoot.find("input").val()).toISOString().replace(/T.*/gi, "") + "T00:00:00.000Z";

var d2 = new Date(Apperyio("endDate").datapickerRoot.find("input").val()).toISOString().replace(/T.*/gi, "") + "T00:00:00.000Z";

var whereObject = {
$and: [{
"createdAt": {
$gt: {
"$date": d1
}
}
}, {
"createdAt": {
$lt: {
"$date": d2
}
}
}]
};
return JSON.stringify(whereObject);

/pre

Regards.

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

Query a date range.

Thank you for the code. I tried that, and I saw the loading indicator load for 10 seconds but then I didn't see the addresses being mapped on the map (i.e no markers).

Also, before, I clicked on List All, and I was able to see the addresses being marked on the map. Now, it's not working for some reason... Is it because the database in large now? It worked perfectly fine in the last few days.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query a date range.

Hi Mike,

It's hard to say what is wrong.

At first you can just set "limit" parameter for you "list" service with value for example: "10".

Then please take a look into browser debugger network tab and find there your request. Open response tab and see what is here.

Regards.

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

Query a date range.

It worked!

The marker "visible" property was not checked. Thank you so much!

Return to “Issues”