1

I am using admin-bro / adminjs to create a CRUD admin portal but some of the fields are date fields and when I tried to Edit an item that already exists and clicked in save Sequelize gives me this error:

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

Anyone that has overcome this problem?

Ziolek
  • 142
  • 6
lumayara
  • 402
  • 6
  • 16

1 Answers1

1

I am using Sequelize with MSSQL and it seems like Sequelize only accepts Date, Date(6) and DateOnly as types. The type in my database is DATETIME and for some reason when I edit it sends to sequelize the "YYYY-MM-DDTHH:MM:SSz" string and it has trouble converting it. My temporary solution was to change the type in my sequelize model to DATEONLY.

ModifiedOn: {
      type: DataTypes.DATEONLY,
      allowNull: true,
      defaultValue: Sequelize.Sequelize.fn('getdate')
},

For now this is what I will be using but I am trying to find a way to keep record of the time as well.

lumayara
  • 402
  • 6
  • 16