Gabriel Bizcarra
Posts: 0
Joined: Sun Dec 22, 2013 1:02 am

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

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()}}

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

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

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

Gabriel Bizcarra
Posts: 0
Joined: Sun Dec 22, 2013 1:02 am

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

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

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

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

Gabriel Bizcarra
Posts: 0
Joined: Sun Dec 22, 2013 1:02 am

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

Worked it out.

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

Thanks for your help.

Return to “Issues”