How to convert ISO Date to UTC date in Hive

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 format: select from_unixtime(UNIX_TIMESTAMP(“2017-01-01T05:01:10Z”, “yyyy-MM-dd’T’HH:mm:ss’Z'”),”yyyy-MM-dd HH:mm:ss”); Result: 2017-01-01 05:01:10 Update. This method is to remove Z and replace T with space using regexp_replace and convert to timestamp if necessary, without using unix_timestamp(), this will … Read more

Create an ISODate with pyMongo

You just need to store an instance of datetime.datetime. Inserting from the python shell: >>> c.test.test.insert({‘date’: datetime.datetime.utcnow()}) ObjectId(‘4e8b388367d5bd2de0000000′) >>> c.test.test.find_one() {u’date’: datetime.datetime(2011, 10, 4, 16, 46, 59, 786000), u’_id’: ObjectId(‘4e8b388367d5bd2de0000000’)} Querying in the mongo shell: > db.test.findOne() { “_id” : ObjectId(“4e8b388367d5bd2de0000000”), “date” : ISODate(“2011-10-04T16:46:59.786Z”) }

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

Although $date is a part of MongoDB Extended JSON and that’s what you get as default with mongoexport, I don’t think you can really use it as a part of the query. If try exact search with $date like below: db.foo.find({dt: {“$date”: “2012-01-01T15:00:00.000Z”}}) you’ll get the error: error: { “$err” : “invalid operator: $date”, “code” … Read more