0

I have a collection with string filed which has data like '30-oct-2018 00:00:00' How can i update this filed datatype to Date with out changing its value. ie; ISODate("2018-10-30T00:00:00.000Z")

Saumya Ranjan
  • 75
  • 1
  • 3
  • 11

1 Answers1

0

You should never store date /time values as string, it's a design flaw. Store always proper Date objects. Natively MongoDB does not support month names, you have to use $switch statement with 12 branches.

Or use moment.js to convert. But then you need to use it in a forEach line by line

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110