-
-
Save guilleferrer/1669783 to your computer and use it in GitHub Desktop.
db.Collection.find({ | |
created_at : { | |
'$gte': new Timestamp(new Date(2012, 0, 21), 0), | |
'$lte': new Timestamp(new Date(2012, 0, 22), 0) | |
}) |
is there a way to search records from mongo db collection before one hour from its actual flight time ?
Don't think this is right. I think you need to getTime() and then divide by 1000:
db.Collection.find({
created_at : {
'$gte': new Timestamp((new Date(2012, 0, 21)).getTime()/1000, 0),
'$lte': new Timestamp((new Date(2012, 0, 22)).getTime()/1000, 0)
})
I have a problem here!
Let us say I have two date attributes in object like below (fromDate and toDate)
{ "_id" : ObjectId("5b6177ae5c9f723dc414f53f"), "employeeName" : "Sridhar Bellide", "employeeId" : "823284", "fromDate" : ISODate("2018-08-10T00:00:00Z"), "toDate" : ISODate("2018-08-20T00:00:00Z"), "team" : "Game of Rules", "leaveType" : "Casual", "__v" : 0 }
So, inserted dates are fromDate is 10 Aug and toDate is 20 Aug.
My question is if I have input like fromDate selected as 8 Aug and endDate selected as 15 Aug, I want that object to be extracted from MongoDB.
What query I need to use for this? please help!
Thanks & Regards,
Sridhar
in mongoose type:Date.
on Schema do this
ex.: entry_date:{type:Date}