Reputation: 79
I have to create a table with MySql which can store date in the following format : I tried smth like :
CREATE TABLE birth (
....
date DATE,
......
);
But it doesn't work since DATE format is YYYY/MM/DD... How can I do ?
Thanks ;)
Upvotes: 3
Views: 12550
Reputation: 1269753
Dates do not have a "format" in MySQL (or in almost any other database). They are stored in some internal format, that is eventually presented to the user.
If you want the date in a particular format, use dateformat()
for output. In your case, dateformat(datecol, '%Y/%m/%d')
.
For input, use the ISO standard format (YYYY-MM-DD) or str_to_date()
with the same formatting conventions.
Upvotes: 3