Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Apply filter on date in mongodb

I have a field named RechargeDate in mongo :

"Recharge_Date" : ISODate("2022-06-13T00:00:00.000Z")

Now, I need to apply filter on it based on today's date. If today's date is any of 1 to 10 of a month, then filter should be such that when it gets applied on find function of mongoose, it fetches the record between 1 to 10th of Month of Recharge_Date.

Similarly, if today's date is any of 11 to 20 of a month, then filter should be such that when it gets applied on find function of mongoose, it fetches the record between 11 to 20th of Month of Recharge_Date.

I want to know how the filter query would look like.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You can use moment.js or similar library:

db.collection.find({ 
  Recharge_Date: {
     $gte: moment().startOf('day').toDate(),
     $lte: moment().endOf('day').toDate()
  }
})
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!