0

I use myModel.find();
Results:

 {
    _id : "5afe3beb6fb6b70bfffaff13",
    name: "test01",
    birthday:   "Mon Jun 04 2018 14:56:46 GMT+0700 (+07)",           
},
{
    _id : "5afe3beb6fb6b70bfffafrr13",
    name: "test02",
    birthday:  "Mon Jun 04 2018 14:56:46 GMT+0700 (+07)",       
},

How to convert "birthday" field from ISODate to (Y-m-d) ?
Note:Don't update database
Results wish:

  {
    _id : "5afe3beb6fb6b70bfffaff13",
    name: "test02",
    birthday:  "2018-06-06",       
},
{
    _id : "5afe3beb6fb6b70bfffafrr13",
    name: "test02",
    birthday:  "2018-06-06",   

},

Thanks for your time!

David
  • 1
  • 1
  • Hey @NeilLunn ! I'm did edit question. Can you reviews it again ? – David Jun 06 '18 at 07:46
  • You have the wrong operator and I think you mean [`$dateFromString`](https://docs.mongodb.com/manual/reference/operator/aggregation/dateFromString/), but it won't just convert "any" format. And it does not think your "strings" are valid. Marked to the different duplicates of this question. Please don't change the question again. – Neil Lunn Jun 06 '18 at 08:01
  • Sorry mate! .Your answer not right my request.I search but not result. I need result like same on mongodb [link here](https://docs.mongodb.com/manual/reference/operator/aggregation/dateToString/) – David Jun 06 '18 at 08:46

0 Answers0