Categories
Development MongoDB

how to check date $gte in mongodb for ‘dd.mm.YYYY’ date format

I want data where deliveryDate is greater than equal to current date but it is not working in mongodb. my deliveryDate are stored in “11.8.2018” this format.

collection.aggregate([
{
  $match: {"deliveryDate" : { $gte: new Date(new Date().setDate(new.  Date().getDate()-2)) }
},{
 $group: {
      _id:{
           year: { $year: "$createdDate" },
           month: { $month: "$createdDate" },
           day: { $dayOfMonth: "$createdDate" },
           time: { $dateToString: { format: "%H:%M:%S:%L", date: "$createdDate" }},
           partialAmount : "$partialAmount",
           balanceAmount : "$balanceAmount"
         }
      }
 },
])}  

but this is not working if I give create date instead of deliveryDate then it is working but I want them according to deliveryDate.

Leave a Reply

Your email address will not be published. Required fields are marked *