isodate

MongoDB + nodejs : how to query ISODate fields?

被刻印的时光 ゝ 提交于 2019-11-26 20:51:51
问题 I am using nodejs with the node-mongodb-native driver (http://mongodb.github.io/node-mongodb-native/). I have documents with a date property stored as ISODate type. Through nodejs, I am using this query: db.collection("log").find({ localHitDate: { '$gte': '2013-12-12T16:00:00.000Z', '$lt': '2013-12-12T18:00:00.000Z' } }) It returns nothing. To make it work I need to do the following instead: db.collection("log").find({ localHitDate: { '$gte': ISODate('2013-12-12T16:00:00.000Z'), '$lt':

Create an ISODate with pyMongo

与世无争的帅哥 提交于 2019-11-26 17:38:43
问题 I've been trying to find a way to create an ISODate object whith pyMongo client, but without any success so far. I use http://pypi.python.org/pypi/pymongo3 client, which is the only serious one available in Python 3 for now, but the problem doesn't seem to come from this specific pymongo version. I'd like to know if any of you has found a solution to use this MongoDB object type from a pymongo client... thanks for your help ! 回答1: You just need to store an instance of datetime.datetime.

Date query with ISODate in mongodb doesn't seem to work

社会主义新天地 提交于 2019-11-26 15:04:46
I don't seem to be able to get even the most basic date query to work in MongoDB. With a document that looks something like this: { "_id" : "foobar/201310", "ap" : "foobar", "dt" : ISODate("2013-10-01T00:00:00.000Z"), "tl" : 375439 } And a query that looks like this: { "dt" : { "$gte" : { "$date" : "2013-10-01T00:00:00.000Z" } } } I get 0 results from executing: db.mycollection.find({ "dt" : { "$gte" : { "$date" : "2013-10-01T00:00:00.000Z"}} }) Any idea why this doesn't work? For reference, this query is being produced by Spring's MongoTemplate so I don't have direct control over the query

How to convert ISO Date to UTC date in Hive

巧了我就是萌 提交于 2019-11-26 14:42:13
问题 I have JSON data as below: I need to convert that date or mongo_date into utc timestamp, to analyse the data in hive as per timeline example per year, per month, per week using map reduce { "_id" : ObjectId("51ac77050e9edcdad271ce2d"), "company" : null, "date" : "19760224", "mongo_date" : ISODate("1976-02-24T00:00:00Z") 回答1: Hive understands this format: 'yyyy-MM-dd HH:mm:ss.SSS' . Use unix_timestamp() to convert to seconds passed from 1970-01-01, then use from_unixtime() to convert to proper

Formatting ISODate from Mongodb

不想你离开。 提交于 2019-11-26 12:58:21
问题 In Mongodb I am storing date and time in ISODate format. Which looks like this ISODate(\"2012-07-14T01:00:00+01:00\") Using nodejs/javascript, how can I display the time component so I would get something like this Time : 01:00 I am using momentjs to make this easier but from what I can tell momentjs does seem to support the ISODate format. Thanks for you help. 回答1: JavaScript's Date object supports the ISO date format, so as long as you have access to the date string, you can do something

convert iso date to milliseconds in javascript

让人想犯罪 __ 提交于 2019-11-26 10:30:33
问题 Can I convert iso date to milliseconds? for example I want to convert this iso 2012-02-10T13:19:11+0000 to milliseconds. Because I want to compare current date from the created date. And created date is an iso date. 回答1: Try this var date = new Date("11/21/1987 16:00:00"); // some mock date var milliseconds = date.getTime(); // This will return you the number of milliseconds // elapsed from January 1, 1970 // if your date is less than that date, the value will be negative EDIT You've provided

Date query with ISODate in mongodb doesn't seem to work

左心房为你撑大大i 提交于 2019-11-26 04:08:57
问题 I don\'t seem to be able to get even the most basic date query to work in MongoDB. With a document that looks something like this: { \"_id\" : \"foobar/201310\", \"ap\" : \"foobar\", \"dt\" : ISODate(\"2013-10-01T00:00:00.000Z\"), \"tl\" : 375439 } And a query that looks like this: { \"dt\" : { \"$gte\" : { \"$date\" : \"2013-10-01T00:00:00.000Z\" } } } I get 0 results from executing: db.mycollection.find({ \"dt\" : { \"$gte\" : { \"$date\" : \"2013-10-01T00:00:00.000Z\"}} }) Any idea why