'Python Datetime.datetime is not giving me results in mongodb aggregate
startTime and endTime is a datetime object, same query gives me the desired results on Mongodb Compass.
pl = [
{
"$match": {
"clientId": id_,
"Date": {
"$gt": startTime,
"$lt": endTime
}
}
},
{
"$sort": {
"Date": -1
}
},
{
"$lookup": {
"from": "Intake",
"let": { "searchId": { "$toObjectId": "$intakeId" } },
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [ "$_id", "$$searchId" ]
}
}
},
{
"$project": {
"PatientID": 1,
"First Name": 1,
"Last Name": 1,
"Status": 1,
"StatusDate": 1
}
}
],
"as": "info"
}
}
]
cursor = mydb.transaction.aggregate(pl)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
