Reputation: 1831
How do I convert a String like "11/21/2012" to Date in MongoDB?
I tried the following
obj.as_from = ISODate("11/21/2012");
and got this error
uncaught exception: invalid ISO date
Is there a simple way to convert the string above?
Upvotes: 2
Views: 5016
Reputation: 10530
As pointed by user602525, in the Mongo shell.
obj.as_from = new Date("11/21/2012");
Do not forget to use the new
operator.
Upvotes: 4