MongoDB查询operation表中statusoperStartTime这个字段在3月18日到4月17日内每天1500到1730的数据
以下是MongoDB查询语句:
db.operation.find({
"status.operStartTime": {
$gte: ISODate("2021-03-18T15:00:00.000Z"),
$lte: ISODate("2021-04-17T17:30:00.000Z")
},
$expr: {
$and: [
{
$eq: [
{ $hour: "$status.operStartTime" },
15
]
},
{
$gte: [
{ $minute: "$status.operStartTime" },
0
]
},
{
$lte: [
{ $minute: "$status.operStartTime" },
59
]
}
]
}
})
这个查询语句使用了$gte和$lte操作符来限制查询时间范围,使用了$expr操作符和内部的$and、$eq、$gte和$lte操作符来限制查询每天的时间范围。其中,$hour和$minute操作符用于提取日期时间中的小时和分钟
原文地址: https://www.cveoy.top/t/topic/cEAB 著作权归作者所有。请勿转载和采集!