Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import a date(ISODate) into MongoDB using mongoimport

Tags:

mongodb

I have this MongoDB document. In JSON:

{
"attString":"hello World0",
"attInt":0,
"attDate":new Date("1990-7-20")
 }
        

How can I import this document into MongoDB using mongoimport? I have a problem with the attDate field.

This is MongoDB shell notice:

Failed: error unmarshaling bytes on document #1: unexpected ISODate format

like image 888
DistribuzioneGaussiana Avatar asked Oct 13 '15 15:10

DistribuzioneGaussiana


1 Answers

You have to change your date format in JSON

Either

{"attString":"hello World0","attInt":0,"attDate":ISODate("2013-11-20T23:32:18Z")}

OR

{"attString":"hello World0","attInt":0,"attDate":{"$date":"2013-11-20T23:32:18Z"}} 

Hope it will help

like image 93
Rohit Jain Avatar answered Sep 28 '22 04:09

Rohit Jain