Page 1 of 1

How can I query a date column with a where clause based on the current date?

Posted: Sun Dec 22, 2013 1:02 am
by Gabriel Bizcarra

The following where clause works:
{'DateStart': {"$gte": "2014-07-14 00:00:00.000"}}

I want to replace the date part with the current date. Is there a current date function I can call? eg.

{'DateStart': {"$gte": CurrentDate()}}


How can I query a date column with a where clause based on the current date?

Posted: Sun Dec 22, 2013 1:21 am
by maxkatz

You can do that with JavaScript.. just search for the right function. There are also libraries out there that can help you.


How can I query a date column with a where clause based on the current date?

Posted: Sun Dec 22, 2013 12:15 pm
by Gabriel Bizcarra

Ok so i've found some other references and have modified very slightly to get

var d = new Date();
d.setDate(d.getDate());
var dateStr = d.toISOString();
return '{"DateStart":{"$gte":"'+ dateStr +'"}}';

dumb question, where do i put it?

I'm in the query_service, test tab and putting this in the where clause but it's failing


How can I query a date column with a where clause based on the current date?

Posted: Sun Dec 22, 2013 5:47 pm
by maxkatz

In the Tab tab you place actual values. You can place this code when you map, in the JavaScript function.


How can I query a date column with a where clause based on the current date?

Posted: Tue Dec 24, 2013 7:36 am
by Gabriel Bizcarra

Worked it out.

I put it in the Page\Data Tab\Request Tab in the Where statement using JS.

Thanks for your help.