I have this code to build a table:
CREATE TABLE Course
(
CustomerName varchar(30) NOT NULL, Title varchar (30) NOT NULL,
Type varchar(30) NOT NULL, Instructor varchar(30) NOT NULL, StartDate Date NOT NULL, EndDate Date NOT NULL,
Price float NOT NULL
);
When I try to insert something into the Course table, the date says it is the wrong format. It either says the date cant hold integer or string. How do I enter the date so that it will except it? Below are all the ways I have tried:
INSERT INTO Course(CustomerName, Title, Type, Instructor, StartDate,EndDate,Price) VALUES ('Hary','Intro to Stupidity', 'Programming','Davis', 2017/11/12, 2017/04/03, 124.00);
INSERT INTO Course(CustomerName, Title, Type, Instructor, StartDate,EndDate,Price) VALUES ('Hary','Intro to Stupidity', 'Programming','Davis', 2017-11-12, 2017-04-03, 124.00);
INSERT INTO Course(CustomerName, Title, Type, Instructor, StartDate,EndDate,Price) VALUES ('Hary','Intro to Stupidity', 'Programming','Davis', 2017.11.12, 2017.04.03, 124.00);
INSERT INTO Course(CustomerName, Title, Type, Instructor, StartDate,EndDate,Price) VALUES ('Hary','Intro to Stupidity', 'Programming','Davis', (2017/11/12), (2017/04/03), 124.00);
If anyone could help that would be great!
PreapredStatements ability to handle date/time types directly and let the underlying driver deal with it - See Using Prepared Statements for more details