Reputation: 51
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
Upvotes: 1
Views: 4450
Reputation: 142366
Perhaps you are referring to this? DATETIME
and TIMESTAMP
have an optional length. It refers to the number of decimal places (up to 6) for fractional seconds. Certain other functions also have this convention:
mysql> SELECT NOW(), NOW(6);
+---------------------+----------------------------+
| NOW() | NOW(6) |
+---------------------+----------------------------+
| 2021-12-10 22:56:14 | 2021-12-10 22:56:14.927507 |
+---------------------+----------------------------+
(But, I don't think you need the parens on DATETIME
.)
Upvotes: 0
Reputation: 37099
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');
Upvotes: 1