Hi
I want to construct a dynamic where clause to check current date/time is within a date/time range (start, end).
Can I do the same with a +1 or -1 hour range?
Thanks.
Hi
I want to construct a dynamic where clause to check current date/time is within a date/time range (start, end).
Can I do the same with a +1 or -1 hour range?
Thanks.
This seems to work
I will check further
var d = new Date();
d.setDate(d.getDate());
var dateStr = d.toISOString();
return '{"DateStart":{"$gte":"'+ dateStr +'"}}';
Example
{$and: [{ "ValidFrom": {$lte: "2014-11-11T00:00:00.000Z"} },{ "ValidTo": {$gte: "2014-11-11T00:00:00.000Z"} } ] }
Hello Panagiotis,
The toISOString() method returns a string in ISO format (ISO 8601 Extended Format), which can be described as follows: YYYY-MM-DDTHH:mm:ss.sssZ. The timezone is always UTC as denoted by the suffix "Z".
read more here https://developer.mozilla.org/en-us/d...
You can add the offset of a timezone to the date to obtain the desired value
https://developer.mozilla.org/en-us/d...
prevar d = new Date();
d.setHours(d.getHours(), d.getMinutes() - d.getTimezoneOffset());
var dateStr = d.toISOString();
alert (dateStr);/pre
Thanks! it works Fine!