Open chemitaxis opened 7 years ago
This fix date like this:
ISODate("2016-05-11T15:06:37.638Z") // This is an object ;)
I have fixed DATETIME and DATE objects, I think TIME has a different behaviour. Please tell me if I'm right.
Hi, I'm trying to understand the spec of MongoDB.
In Mongo shell, we can create a Date
object, and internally it is ISODate
, according to its text. Here're my quick study and results:
replicaset:PRIMARY> var d = new Date()
replicaset:PRIMARY> d
ISODate("2017-07-07T13:15:22.921Z")
replicaset:PRIMARY> typeof d
object
replicaset:PRIMARY> d instanceof ISODate
false
replicaset:PRIMARY> d instanceof Date
true
replicaset:PRIMARY> var dd = new ISODate()
replicaset:PRIMARY> dd
ISODate("2017-07-07T13:18:34.296Z")
replicaset:PRIMARY> dd instanceof ISODate
false
replicaset:PRIMARY> dd instanceof Date
true
Date()
behavior is the same as ISODate
Date
ISODate
So, it seems that we can detect a date object by val instanceof Date
.
@chemitaxis I've updated the code a bit for clarification and readability. a31e152df9322b875672721265654ab3ed0be90c Could you pls check that the updated version still work in your environment? Thanks.
Hi @cognitom sorry for the delay... I can tell you that your approach if correct, here you have a screenshot after import my data users. Thanks.
Doesn't that work for me, any suggestions? @cognitom My DATETIME is '2018-07-01T12:34:00.000Z', but in import to MySQL, the result is NULL.
Hi, my MongoDB Collection is returning an object instead of a number or string, I have changed the code:
I think this error could happen too in other date formats, but with DATETIME is fixed for me. I have created a PR, please check. Thanks and excellent work ;)