How to add current date in RobomongoDB

3,340 views
Skip to first unread message

NileshM

unread,
Apr 26, 2016, 10:31:14 AM4/26/16
to mongodb-user
i want to insert exact current date in mongoDB throw robo mongo.
PFA
mongo insert date issue.png

NileshM

unread,
Apr 27, 2016, 2:16:23 AM4/27/16
to mongodb-user
Hey How to insert ?

Chris Cunningham

unread,
May 2, 2016, 2:47:33 AM5/2/16
to mongodb-user
Nilesh,

Because Robomongo embeds the mongo shell, you should be able to add the current date like the following example:

{
    "date" : ISODate("2016-05-26T00:00:00.000Z"),
    "userId" : NumberLong(10),
    "name" : "Green Tea with honey",
    "calss" : "BSC-SE",
    "createdAt" : new ISODate()
}

This works because the MongoDB shell is a JavaScript REPL, so you are able to utilize JavaScript constructors to simplify tasks.

Additional information on new ISODate()can be found in the MongoDB documentation at:


Please let us know if you have any further questions.

Regards,

Chris 

Mane Nilesh

unread,
May 2, 2016, 6:05:27 AM5/2/16
to mongod...@googlegroups.com, chris.cu...@mongodb.com
issue not solved

PFA

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/qDECOYroWRc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/aaa5807d-f8fa-4ee8-9ae1-871d9abaf436%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,
Nilesh



Untitled.jpg

Chris Cunningham

unread,
May 2, 2016, 7:46:31 PM5/2/16
to mongodb-user, chris.cu...@mongodb.com

Nilesh,


After further analysis, it has been found that there is a known issue with Robomongo that indicates that there is a problem with the way that it performs JSON validation:


https://github.com/paralect/robomongo/issues/619


It appears that the validation process in Robomongo is not able to use constructors as per the example I provided.


You may want to reach out to the Robomongo developers to see if they intend to address this issue in future releases:


https://github.com/paralect/robomongo/issues


Using the Robomongo -> Insert Document function, you will need to specify a date string in the ISODate() instead of letting the constructor create it for you as shown in the following example:



{ 
    "date" : ISODate("2016-05-26T00:00:00.000Z"), 
    "userId" : NumberLong(10), 
    "name" : "Green Tea with honey", 
    "calss" : "BSC-SE", 
    "createdAt" : ISODate("2016-05-26T00:00:00.000Z") 
}


Alternatively, you can add the document from the command line at the top of Robomongo using the following example:


db.test.insert({ "date" : ISODate("2016-05-26T00:00:00.000Z"),  
    "userId" : NumberLong(10),  
    "name" : "Green Tea with Honey",  
    "calss" : "BSC-SE",  
    "createdAt" : new ISODate() })


Please let us know if you have any questions.


Regards,


Chris

issue not solved

PFA

To unsubscribe from this group and all its topics, send an email to mongodb-user+unsubscribe@googlegroups.com.



--
Cheers,
Nilesh



Mane Nilesh

unread,
May 5, 2016, 1:45:30 AM5/5/16
to mongod...@googlegroups.com
Thanks Chris.

issue not solved

PFA

To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.



--
Cheers,
Nilesh



--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/qDECOYroWRc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.

To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.

For more options, visit https://groups.google.com/d/optout.



--
Cheers,
Nilesh



Reply all
Reply to author
Forward
0 new messages