Reputation: 4393
I am familiar with DATE_FORMAT
function which can display the the record from my date field in the format specified. However, I would like to create a table with a date field that only accepts my format.
Here's 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 a date_hired value of '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 the way it was inserted). Any feedback? Did I miss something?
Thanks,
Michael
Upvotes: 9
Views: 38707
Reputation: 126
You can't change the format during table create, you can change the format of date for displaying user by using you programming logic like if you are using PHP as your server side language the you can convert it your desired format.
Upvotes: 11