Home > Software design >  What should the Length/Value be for "DATE" data type in mysql?
What should the Length/Value be for "DATE" data type in mysql?

Time:10-21

I looked for the answer to this question before posting this but I couldn't find it. I'm sorry if it has been asked before but I would like to know what I should enter for the Length/Value for "DATE" in mysql.

Thanks in advance

enter image description here

CodePudding user response:

You don't need to provide a length. Just do:

create table test (
 id int,
 created_date date,
 modified_date date
);

See https://dev.mysql.com/doc/refman/5.7/en/date-and-time-type-syntax.html for documentation.

You can insert data with insert into test values (1, '2020-01-01', '2020-02-01');

CodePudding user response:

''' select data type DATETIME for date. mysql will autumatically reserve 3 bytes of space for date and several date format is available in my sql. for eg datestamp, Dateonlyformat. create table abc ( id int, registrationDate date ); '''

  • Related