isodate

Change String date to ISO date in MongoDB?

心不动则不痛 提交于 2019-12-11 06:39:32
问题 In MongoDB, I have a document with a field called "date" and that is in array. { "_id" : ObjectId("587627a2125a730f78a20859"), "data" : [ { "Number" : "359983007479839", "date" : "2016-02-10T21:56:33.000Z" } ] after that I run this script: db.dummy.find().forEach(function(doc){ doc.mongodbdate = ISODate(doc.mongodbdate); db.dummy.save(doc); }) And its giving me below output; { "_id" : ObjectId("588724ba2746360c04a51e4b"), "data" : [ { "Number" : "359983007479839", "mongodbdate" : "2016-02

How to produce a formatted date string in Q/KDB?

天大地大妈咪最大 提交于 2019-12-11 01:24:31
问题 How can one produce an ISO date string "yyyy-MM-dd" from a Q date type? I looked at concatenating the various parts but am not even able to get the day/month, e.g. d:2015.12.01;d.month prints 2015.12 , i.e. more than just the month. 回答1: q)"-" sv "." vs string[2015.12.01] "2015-12-01" vs vector from string, splits by "." above; sv string to vector, join by "-" above. Remember a string is just a char array, so you can grab each part as you require with indexing. But the above is useful as the

MongoDB C++, How to add ISODate value when inserting

做~自己de王妃 提交于 2019-12-07 17:18:45
问题 This is about the new MongoDB C++ Driver (not the legacy one). I can insert a document this way: value Value = document{} <<"Key" <<"Value" <<finalize; cxxClient["db"]["collection"].insert_one(Value.view()); The above code insert a document with 1 field 'Key' of value 'Value'. I can insert string, int, float,... but just can't figure out how to insert ISODate. The new MongoDB C++ Driver should come with more examples in documentation. 回答1: Thanks Styvane, I found it out how! value Value =

JavaScript - How to save a date in MongoDB document in ISODate format?

不打扰是莪最后的温柔 提交于 2019-12-05 14:33:34
I have been trying to save the date from javascript side into MongoDB in ISODate format. But it just saves the date field in my MongoDB document in string format. Here is the object I'm sending into the MongoDB to be saved as a document in a given collection. var currentDate = new Date(); postData = { deviceID: deviceID, companyID: companyID, userID: userID, date: currentDate }; Everything works fine except the date field is just saved in String format. Couldn't find any SO question which could give a clear answer for this problem as well, if there is a one please direct me to the proper place

mongodb ISODate problems

回眸只為那壹抹淺笑 提交于 2019-12-04 12:23:49
I am using java(IDE is eclipse) to query on mongodb. Below is my java code: DBObject query = new BasicDBObject(); ObjectId id =new ObjectId("529f280b90ee58cb7732c2b8"); query.put("_id", id); DBCursor cursor = collection.find(query); while(cursor.hasNext()) { DBObject object = (DBObject)(cursor.next()); System.out.println(object.get("_id")); System.out.println(object.get("createDate")); } Problems happened in the createDate whose type is ISODate and value is ISODate("2013-10-21T01:34:04.808Z") , but the println result of my code is 'Mon Oct 21 **09**:34:04 CST 2013' , the hour has changed from

Get the “Right” Year of a Certain Date with PHP DateTime

你。 提交于 2019-12-02 07:20:19
问题 I was trying to transform a date "YYYY/MM/DD" into "YYYY/WW" format, so I can store the weekly aggregation data, which has a structure below aggre_date(YYYY/WW) value id But I found a nasty problem $dateTime = new DateTime("2014-12-30"); echo $dateTime->format("Y-W")."\n"; $dateTime = new DateTime("2014-01-01"); echo $dateTime->format("Y-W")."\n"; The result is exactly same 2014-01 , but the former should be 2015-01 . Is there any way to improve my weekly aggregation data design or to get the

ISO 8601 Date JS Interpretation Difference - IE/FF versus Chrome

六眼飞鱼酱① 提交于 2019-12-01 12:16:17
Why do IE/FF and Chrome javascript engines differ on how to interpret this Date format ( YYYY-MM-DDTHH:mm:ss.fff ) without the timezone designator? new Date("2015-02-18T15:43:57.803").getUTCHours() UTC Hours Chrome: 15 IE11/FF: 21 I don't understand this - is it because Chrome assumes it's local whereas IE/FF assume it's UTC? This seems like a Chrome bug. Interestingly - appending a "Z" to the end of the string tells both Chrome and IE/FF that the time is UTC and they can agree. Has anyone else noticed this javascript implementation discrepancy with Date ? new Date("2015-02-18T15:43:57.803Z")

Mongoexport -q ISODate query

*爱你&永不变心* 提交于 2019-11-30 19:12:41
I'm trying to run this: mongoexport.exe -h *MYHOST* -p *MYPORT* -q "{'time':{'$gte': ISODate('2014-12-21 12:57:00.506Z'),'$lt': ISODate('2014-12-21 12:59:00.506Z')}}" Or this(the gte & lt without - ' ): mongoexport.exe -h *MYHOST* -p *MYPORT* -q {'time':{$gte: ISODate('2014-12-21 12:57:00.506Z'),$lt: ISODate('2014-12-21 12:59:00.506Z')}} The query works fine on Robomongo, But with mongoexport it throws: "too many positional arguments" I know I can run the following instead, But I don't want to use the date converter everytime I need to execute a query. mongoexport.exe -h *MYHOST* -p *MYPORT*

Remove Seconds/ Milliseconds from Date convert to ISO String

只谈情不闲聊 提交于 2019-11-30 14:33:46
问题 I have a date object that I want to remove the miliseconds/or set to 0 remove the seconds/or set to 0 Convert to ISO string For example: var date = new Date(); //Wed Mar 02 2016 16:54:13 GMT-0500 (EST) var stringDate = moment(date).toISOString(); //2016-03-02T21:54:13.537Z But what I really want in the end is stringDate = '2016-03-02T21:54:00.000Z' 回答1: While this is easily solvable with plain javascript (see RobG's answer), I wanted to show you the momentjs solution since you tagged your

Remove Seconds/ Milliseconds from Date convert to ISO String

六月ゝ 毕业季﹏ 提交于 2019-11-30 10:53:17
I have a date object that I want to remove the miliseconds/or set to 0 remove the seconds/or set to 0 Convert to ISO string For example: var date = new Date(); //Wed Mar 02 2016 16:54:13 GMT-0500 (EST) var stringDate = moment(date).toISOString(); //2016-03-02T21:54:13.537Z But what I really want in the end is stringDate = '2016-03-02T21:54:00.000Z' While this is easily solvable with plain javascript (see RobG's answer), I wanted to show you the momentjs solution since you tagged your questions as momentjs : moment().seconds(0).milliseconds(0).toISOString(); This gives you the current datetime,