According to Between Dates using Waterline ORM SailsJS it is possible to do a between query on dates in the Waterline adapter like the following:
User.find({
createdAt: { '>': dateFrom, '<': dateTo }
}).exec(/* ... */);
However, this does only work with date formats like 2018-04-11. Is it somehow possible to use the full ISO8601 date format in this query: e.g. 2018-04-11T12:45:00.000Z?
EDIT: Added minimal working example code.
readDataInDateRange: function(req, res) {
var dateFrom = req.param("dateFrom");
if (dateFrom == null || dateFrom == ''){
return res.badRequest();
}
var dateTo = req.param("dateTo");
if (dateTo == null || dateTo == ''){
return res.badRequest();
}
User.find({createdAt: { '>=': dateFrom, '<=': dateTo}})
.exec(function afterwards(err, users) {
if (err) {
sails.log(err);
return res.serverError(err);
}
return res.ok(users);
});
}