How can I fix 'Error 1364: field 'Date' doesn't have a default value' in MySQL?

138 Views Asked by At

Error 1364: field 'Date' doesn't have a default value.

in the following table I've created in my server, as well as most others, i'm running into the error above when inputting my date values, and I'm unsure how to fix it. the table is as follows:

CREATE TABLE IF NOT EXISTS `mydb`.`enrollment` (
  `EnrollmentId` VARCHAR(10) NOT NULL,  
  `Date` DATETIME NOT NULL, 
  `SchoolId` VARCHAR(20) NOT NULL,
  PRIMARY KEY (`EnrollmentId`),
  INDEX `fk_Enrollment_School1_idx` (`SchoolId` ASC) VISIBLE,
  CONSTRAINT `fk_Enrollment_School1`
    FOREIGN KEY (`SchoolId`)
    REFERENCES `mydb`.`school` (`SchoolId`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION); 

here is the statements for the table:

 INSERT INTO enrollment (EnrollmentId) VALUES 
 ('pegsue5687'),
 ('dangia4965'),
 ('leegun3465'), 
 ('harkan5690'), 
 ('donsal8774'); 
 
INSERT INTO enrollment (Date) VALUES
('03/01/2023'),
('03/05/2023'),
('03/06/2023'),
('03/04/2023'),
('03/07/2023');

INSERT INTO enrollment (SchoolId) VALUES
('tafesa87678645'),
('tafesa87678645'),
('tafesa87678645'),
('tafesa87678645'),
('tafesa87678645');

I've tried disabling strict mode, but that hasn't resolved the issue. any help appreciated

0

There are 0 best solutions below