Database
[{_id:ObjectId("656efc1366c7dce6da3185e3"),a:"656e5e0c6c773c4374b0b14a",b:"656e5e346c773c4374b0b14b",c:"abc",d:"656dbcda6c773c4374b0b125",e:"656e5e346c773c4374b0b14d",f:1,date:"2023-12-05 02:31:47"},{_id:ObjectId("656efc1466c7dce6da3185e5"),a:"656e5e0c6c773c4374b0b14a",b:"656e5e346c773c4374b0b14b",c:"def",d:"656dbcda6c773c4374b0b125",e:"656e5e346c773c4374b0b14d",f:2,date:"2023-12-05 10:31:48"}]
Query
db.collection.aggregate([/**match whatever you want*/{$match:{"d":"656dbcda6c773c4374b0b125","b":"656e5e346c773c4374b0b14b"}},{"$addFields":{"formattedDate":{"$dateFromString":{dateString:"$date",format:"%Y-%m-%d %H:%M:%S"}}}},{"$facet":{"totalCountStage":[{"$group":{"_id":"totalCount","count":{"$sum":1}}},{"$replaceRoot":{"newRoot":{"$arrayToObject":[[{"k":"$_id","v":"$count"}]]}}}],"countDateWise":[{"$group":{"_id":{"$dateToString":{"date":"$formattedDate","format":"%d/%m/%Y"}},"count":{"$sum":1}}},{"$replaceRoot":{"newRoot":{"$arrayToObject":[[{"k":"$_id","v":"$count"}]]}}}],"countHourWise":[{"$group":{"_id":{"$concat":["between ",{"$dateToString":{"date":"$formattedDate","format":"%H"}},":00-",{$substrCP:[{$add:[{$toLong:{"$dateToString":{"date":"$formattedDate","format":"%H"}}},101]},1,2]},":00"]},"count":{"$sum":1}}},{"$replaceRoot":{"newRoot":{"$arrayToObject":[[{"k":"$_id","v":"$count"}]]}}}],"countDayWise":[{"$group":{"_id":{"$dateToString":{"date":"$formattedDate","format":"%u"}},"count":{"$sum":1}}},{$set:{_id:{$switch:{branches:[{case:{$eq:["$_id","1"]},then:"monday"},{case:{$eq:["$_id","2"]},then:"tuesday"},{case:{$eq:["$_id","3"]},then:"wednesday"},{case:{$eq:["$_id","4"]},then:"thursday"},{case:{$eq:["$_id","5"]},then:"friday"},{case:{$eq:["$_id","6"]},then:"saturday"},{case:{$eq:["$_id","7"]},then:"sunday"}]}}}},{"$replaceRoot":{"newRoot":{"$arrayToObject":[[{"k":"$_id","v":"$count"}]]}}}]}}])