Morning everyone. Just a quick question. In my existing MySql database I've few columns with dates in it. Currently these are yyyy-mm-dd format but now I need to change it all to dd-mm-yyyy format. I've tried select date_format(curdate(), '%d/%m/%Y');
but it doesnt update existing data in my table.Is there any easy way of doing it? Or even if its not easy could you give me some suggestion how to do it please and thank you.
Asked
Active
Viewed 2.6k times
2

Krish R
- 22,583
- 7
- 50
- 59

user2815059
- 329
- 2
- 6
- 12
-
See this answer. http://stackoverflow.com/questions/8338031/mysql-setup-the-format-of-datetime-to-dd-mm-yyyy-hhmmss-when-creating-a-tab – Jorge Campos Nov 18 '13 at 11:48
2 Answers
5
Try using
SELECT DATE_FORMAT(dateColumn,'%d/%m/%Y') AS dateColumn FROM table

vhadalgi
- 7,027
- 6
- 38
- 67
-
It kinda works Vijaykumar. It shows me the single column and the format is changed. But when I go back to my table the content is not affected by my query – user2815059 Nov 18 '13 at 12:00
-
yes that's obvious,if you want this data you can redirect to some other table in your database + if this is working pls accept the answer – vhadalgi Nov 18 '13 at 12:02
-
INSERT INTO stocks_remaining(DATE_FORMAT(Date,"%m/%d/%Y"), Item, Quantity) VALUES("02/05/2017", "mouse", 2) What would be the right syntax for this – Krishna Chalise Feb 04 '17 at 09:47
1
You cann't able to change the default date
format in table. Default DATE
format is 'YYYY-MM-DD'. But you can able to retrive the date
column value as your way.

Krish R
- 22,583
- 7
- 50
- 59