Reputation: 1042
i have a database structure like this
name | birthdate
---------------------------------
varcahr(255) | date
i am inserting date in (yyyy/mm/dd) like this using jquery date pickeer '1985/08/22'
but Mysql store it like '1985-08-22'
there is any way that i can store date like '1985/08/22' i want to store slash not '-'.
Upvotes: 1
Views: 3359
Reputation: 2772
You should store the data in the native date format, for efficiency in calculation, etc. You can control the format of the dates going into the tables and selecting from them in your queriers. For example, you can insert data using the str_to_date function:
INSERT into table1(birthdate)
VALUES STR_TO_DATE('2009/01/01','%m/%d/%y')
For selecting your date, you can use
SELECT DATE_FORMAT(birthdate, '%m/%d/%y')
FROM table1
Upvotes: 3
Reputation: 3158
INSERT INTO table (name, birthdate) VALUES(
'mit', STR_TO_DATE('2009/03/08', '%Y/%m/%d'));
Upvotes: 0
Reputation: 204924
MySQL does not store the date as a specific string. It only represents dates like that. See DATE_FORMAT to display a speccific date representation.
Upvotes: 1