2

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.

1

2 Answers 2

5

Try using

SELECT DATE_FORMAT(dateColumn,'%d/%m/%Y') AS dateColumn FROM table 
Sign up to request clarification or add additional context in comments.

3 Comments

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
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
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
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.

Ref: http://dev.mysql.com/doc/refman/5.1/en/datetime.html

1 Comment

Thanks for the link. Its very handy

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.