I'm not sure if this is a bug, but I cannot insert a row into my MySQL table using a query in Node.JS.
Node.JS code utilizing MySQL2:
await mySqlHelper
.queryDatabaseAsync(
"INSERT INTO Degree VALUES( id = '" +
uuid +
"', userId = '" +
data.userId +
"', degreeType = '" +
data.degreeType +
"', major = '" +
data.major +
"', yearInProgram = '" +
data.yearInProgram +
"', graduationDate = '" +
new Date(data.graduationDate).getFullYear() +
"-" +
(new Date(data.graduationDate).getMonth() + 1) +
"-" +
new Date(data.graduationDate).getDate() +
"');"
)
And the response I get is this:
Error: Incorrect date value: '0' for column 'graduationDate' at row 1
sql: "INSERT INTO Degree VALUES( id = '12345678-1234-1234-1234-123456789123', userId = '12345678-1234-1234-1234-123456789123', degreeType = 'PhD', major = 'Engineering', yearInProgram = '3', graduationDate = '2030-9-1');",
sqlMessage: "Incorrect date value: '0' for column 'graduationDate' at row 1"
I've tried formatting it every way I can, and I do not know why it says it has the value '0'.
Thanks!