0

I currently have this SQL:

CREATE TABLE Demographics(
First_Name            VARCHAR(12) NOT NULL PRIMARY KEY,
Last_Name             VARCHAR(12) NOT NULL,
Birthdate             DATE  NOT NULL
);

INSERT INTO Demographics(First_Name, Last_Name, Birdate) VALUES
('John', 'Smith', '05/18/2005' );

I know that the DATE parameter only allows you to have the format: yyyy-mm-dd, but I was wondering if there is a way to get DATE to accept '05/18/2005' since there are thousands of other inserts exactly like that.

P.Salmon
  • 17,104
  • 2
  • 12
  • 19
  • Not there isn't and it's a datatype not a parameter. You could store as a string but then it wouldn't be a date and you would need to convert to date whenever you need date type arithmetic so I would not recommend this approach. – P.Salmon Oct 17 '22 at 08:20
  • Input format is hard-coded, there's no way to change it. You'll need to parse it explicitly: https://stackoverflow.com/questions/5201383/how-to-convert-a-string-to-date-in-mysql – Álvaro González Oct 17 '22 at 08:22
  • Try running some script (non-mysql) on the inserts so that it would change the dates to the required format and if you need to get the dates in the format you present you can use DATE_FORMAT() mysql function in the select statement – Raizekas Oct 17 '22 at 08:24

0 Answers0