Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda