ใช้ $where และฟังก์ชัน JavaScript
เพื่อค้นหาตามเดือนและวันโดยไม่สนใจปี ให้ใช้ $where ร่วมกับเมธอด getMonth() และ getDate() ของ Date object
> db.demo181.insertOne({"ShippingDate": new ISODate("2020-01-10")});
คำสั่งค้นหาเดือน มกราคม (0) หรือวันที่ 10:
db.demo181.find({ $where: function() { return this.ShippingDate.getMonth() == 0 || this.ShippingDate.getDate() == 10 } })
ผลลัพธ์คืนเอกสารที่ตรงกับเงื่อนไขเดือนหรือวัน