I use mysql library for node.js. The problem is that not all dates are inserted, which is very incomprehensible how this generally works.
I’ll say right away that it’s written on the library page on the github that by creating an object through new Date in js, you can insert data.
Code:
connection.connect(); var date1 = new Date('04.07.2016'); var date2 = new Date('23.06.2013'); var queryObject = { date1: date1, date2: date2 }; connection.query('INSERT INTO test SET ?', queryObject, function (error, results, fields) { if (error) throw error; }); connection.end(); What happens in the database:
mysql> select * from test; +----+------------+-------+ | id | date1 | date2 | +----+------------+-------+ | 4 | 2016-04-07 | NULL | +----+------------+-------+ Why is the date 07/04/2016 inserted, and the second is not?
23.06.2013he is trying to parse the formatmm:dd:yyyyand that does not work. Try writing the month instead of the day in the first place. - Suvitruf ♦04.07.2016- this is April 7, 2016, and the month with number 23 does not exist. - Alex