db.getCollection('Timedata').find(
{
Readings: {
$elemMatch:
{DateTime:
{
$gt: ISODate('2005-07-13 07:42:13.355Z'),
$lt: ISODate('2010-07-13 07:42:13.355Z')
}
}
}
});
db.getCollection('Timedata').aggregate([
{
$match:{
Readings: {
$elemMatch:
{DateTime:
{
$gt: ISODate('2005-07-13 07:42:13.355Z'),
$lt: ISODate('2010-07-13 07:42:13.355Z')
}
}
}
}
},
{
$project: {
_id:1,
Timestamp:1,
Label1:1,
Attr:1,
Readings: {
$filter: {
input: "$Readings",
as: "item",
cond: {
$and: [
{$gt: [ "$$item.DateTime", ISODate('2006-07-13 07:00:13.355Z') ]},
{$lt: ["$$item.DateTime", ISODate('2010-07-15 07:42:13.355Z')]}
]
}
}
}
}
}
])