MySQL - date column format

I am familiar with the DATE_FORMAT function, which can display an entry from my date field in the specified format. However, I would like to create a table with a date field that accepts only my format.

Here is what I have done so far:

 CREATE TABLE test_table ( id INT AUTO_INCREMENT, f_name VARCHAR(40) NOT NULL, l_name VARCHAR(25) NOT NULL, date_hired DATE NOT NULL ); 

Inserting a record with date_value '2013-03-01' will be inserted as '1/03/2013 12:00:00 AM', which is far from my expected result (I would like the format to be the way it was inserted). Any feedback? Did I miss something?

Thanks,
Michael

+8
date mysql format date-format
source share
1 answer

You cannot change the format while creating the table, you can change the date format for displaying the user using your programming logic, for example, if you use PHP as the server language, you can convert it to the desired format.

+8
source share

All Articles