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")
Asked
Active
Viewed 24 times
0
-
Your question does not make any sense. "update" is the same as "change" Either you want to update or not. – Wernfried Domscheit Aug 13 '21 at 12:11
-
https://stackoverflow.com/questions/42887627/how-do-i-create-an-indexes-for-date – Jeremy Thille Aug 13 '21 at 12:20
1 Answers
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