Coder Social home page Coder Social logo

Error if datetime is type object about momy HOT 5 OPEN

cognitom avatar cognitom commented on July 25, 2024 2
Error if datetime is type object

from momy.

Comments (5)

mateusrovedaa avatar mateusrovedaa commented on July 25, 2024 1

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.

from momy.

chemitaxis avatar chemitaxis commented on July 25, 2024

This fix date like this:

ISODate("2016-05-11T15:06:37.638Z") // This is an object ;)

from momy.

chemitaxis avatar chemitaxis commented on July 25, 2024

I have fixed DATETIME and DATE objects, I think TIME has a different behaviour. Please tell me if I'm right.

from momy.

cognitom avatar cognitom commented on July 25, 2024

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
  • The object is an instance of Date
  • The object is not an instance of 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. a31e152
Could you pls check that the updated version still work in your environment? Thanks.

from momy.

chemitaxis avatar chemitaxis commented on July 25, 2024

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.
screen shot 2017-07-10 at 11 18 41

from momy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.