How to convert timestamp filed into dd/mm/yyyy format in mongodb

101 views
Skip to first unread message

Balraj Subramaniyam

unread,
Feb 13, 2015, 5:00:41 AM2/13/15
to mongo...@googlegroups.com

Below is my collection format in mongodb

db.order.insert({
    "Name" : "kazara",
    "Code" : "123A1",
    "Ph" : "9090111111",
    "Time" : Timestamp(1421555870, 0),
    "orderNo" : "00000007",
    "OrderAmt" : 122,
    "ItemInorder" : 1,
    "NetorderAmt" : 122,
    "TaxAmt" : 0,
    "CollectionAmt" : 122,
    "Orderno" : "0010000b00330000",
    "CreatedDate" : Timestamp(1421556121, 1)})

I've one field called Time in my order collection.

I want to extrsact date in the format "dd/mm/yyyy" from the Time filed. Plese help to extract this format. The above script take from robomongo tool..

I've to extract this date format in mongo shell

Andy Schwerin

unread,
Feb 13, 2015, 1:40:25 PM2/13/15
to mongo...@googlegroups.com
This question would be better sent to mongod...@googlegroups.com.  This list is for developers of mongod, not developers who use mongod.  It's a frequent point of confusion.

I can't answer your original question, but I'm surprised to see you using Timestamp in your schema.  One should pretty much always use Date, unless you're storing data from the "ts" field of the mongod oplog.

-Andy

--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev...@googlegroups.com.
To post to this group, send email to mongo...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-dev.
For more options, visit https://groups.google.com/d/optout.

Andy Schwerin

unread,
Feb 13, 2015, 1:41:40 PM2/13/15
to mongo...@googlegroups.com
Oh, sorry, typo in my last message.  It's mongod...@googlegroups.com, not mongodb-users.
Reply all
Reply to author
Forward
0 new messages