0

Trying to do a proof of concept of loading sample tick data into mongo db and the tick archive data is generally in utc and epoch and need to load it as is and output as utc only not local datetimes.

How to insert utc datetime and epoch in mongodb without being cast into utc again and retrieve the same as utc only.

db.equity_ticks.insert(
{
"SNAPSHOT_DTTM" : Date("2013-07-09 19:00:00.000000"),
"CLOSE_DATE" : Date(15895) ,
"PREV_DAY_CLOSE_DATE" : Date(15895) 
}

instead it inserted the local CST and output as CST too !

db.equity_ticks.find().pretty()

{
"_id" : ObjectId("52040942e5171b792b258ae8"),
"SNAPSHOT_DTTM" : "Thu Aug 08 2013 16:10:26 GMT-0500 (CDT)",
"CLOSE_DATE" : "Thu Aug 08 2013 16:10:26 GMT-0500 (CDT)",
"PREV_DAY_CLOSE_DATE" : "Thu Aug 08 2013 16:10:26 GMT-0500 (CDT)"
}

any help is appreciated.

mpaul
  • 3
  • 4
  • what is Date(15895)? I tried it, it always stores current date time, why do you use it? – Jayz Aug 08 '13 at 22:17
  • its the epoch secs i.e. secs from 1/1/1970 0:0:0 etc and was using the date function to convert the epoch to utc datetime.. not working as you see.. – mpaul Aug 09 '13 at 18:45
  • Ok found out the datetiume part!
                                     `> db.bug.insert( { "dateTime": new Date("04-16-2013 19:00:00") } )
    > db.bug.find().pretty();
            "_id" : ObjectId("52055acf889999492527c828"),
            "dateTime" : ISODate("2013-04-16T05:00:00Z")
    }
    `
    – mpaul Aug 09 '13 at 21:19
  • I just found out that this number 15895 is the days since 1970/01/01 – mpaul Sep 17 '13 at 17:33

0 Answers0