0

When I try to insert record using Sequelize V4 with node js, this error occurs:

Conversion failed when converting date and/or time from character string

Above error occurred for createdAt and updatedAt columns.

My code is

  const School = sequelize.define('school_data', {
  id:{
        type:Sequelize.INTEGER,
        primaryKey:true,
        autoIncrement:true,
      },
  osteo_schl_id: Sequelize.STRING,
  osteo_schl_name: Sequelize.STRING,
  reset_status: Sequelize.STRING,
  last_update_dt: Sequelize.DATE,
});

let data = {
    osteo_schl_id:schoolId,
    osteo_schl_name:schoolName,
    reset_status:0
}

School.create(data);
1
  • 1
    add timestamps: false in model Commented Nov 30, 2017 at 5:48

1 Answer 1

1

From the documentation http://docs.sequelizejs.com/manual/tutorial/models-definition.html#timestamps you can set createdAt and updateAt field as timestamps

id:{
        type:Sequelize.INTEGER,
        primaryKey:true,
        autoIncrement:true,
      }
       createdAt: Sequelize.DATE,
      updatedAt: Sequelize.DATE,

if you don't need this just set timestamps:false to model defenition

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.