gpt4 book ai didi

javascript - 为什么过滤时没有找到文件?

转载 作者:行者123 更新时间:2023-11-30 19:15:36 24 4
gpt4 key购买 nike

我正在尝试根据日期获取集合。

收藏

[
{
"_id": ObjectId("5d8570d0f0b406165142b90a"),
"Emp No": "A105EUJ2",
"Emp Name": "CHINKI GUPTA",
"Card No": "29712",
"Department": "WIPRO",
"Gender": "",
"Att Date": ISODate("2019-09-11T18:30:00Z"),
"In Time": ISODate("2019-09-12T04:11:00Z"),
"Out Time": ISODate("2019-09-12T14:26:00Z"),
"Status": "P",
"Late By": "",
"Early By": "",
"Total Hour": "10:15",
"OT Hour": "01:15",
"Location": "",
"id": "A105EUJ2-12-Sep-2019",
"__v": 0
},
{
"_id": ObjectId("5d8570d0f0b406165142b90b"),
"Emp No": "A106NDI7",
"Emp Name": "CHANDER SEKHAR SEKHAR",
"Card No": "35323",
"Department": "IBM",
"Gender": "",
"Att Date": ISODate("2019-09-11T18:30:00Z"),
"In Time": ISODate("2019-09-12T05:55:00Z"),
"Out Time": ISODate("2019-09-12T12:40:00Z"),
"Status": "P",
"Late By": "",
"Early By": "",
"Total Hour": "06:45",
"OT Hour": "00:00",
"Location": "",
"id": "A106NDI7-12-Sep-2019",
"__v": 0
},
{
"_id": ObjectId("5d8570d0f0b406165142b90c"),
"Emp No": "A10CIDZX",
"Emp Name": "SANDEEP KUMAR SINGH",
"Card No": "41629",
"Department": "ACCENTURE",
"Gender": "",
"Att Date": ISODate("2019-09-11T18:30:00Z"),
"In Time": ISODate("2019-09-12T04:49:00Z"),
"Out Time": ISODate("2019-09-12T13:46:00Z"),
"Status": "P",
"Late By": "",
"Early By": "",
"Total Hour": "08:57",
"OT Hour": "00:00",
"Location": "",
"id": "A10CIDZX-12-Sep-2019",
"__v": 0
}
]

https://mongoplayground.net/p/PGji97i5xGj

db.collection.aggregate([
{
$match: {
"Att Date": {
$gte: "2019-09-01",
$lte: "2019-09-30"
}
}
}
])

预期输出

应该获取所有文档。

最佳答案

您正在比较 "2019-09-01", 一个字符串与 ISODate("2019-09-11T18:30:00Z") 一个日期

尝试比较日期和日期

db.collection.aggregate([
{
$match: {
"Att Date": {
$gte: ISODate("2019-09-01"),
$lte: ISODate("2019-09-30")
}
}
}
])

关于javascript - 为什么过滤时没有找到文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58036456/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com