I have created a table called event and it has a column birthday which is using the date format of %Y-%m-%d
but I want it to be %d-%m-%Y
. so, how can i update it?
when I enter new row with the format %d-%m-%Y
it converts it to 0000-00-00 (%Y-%m-%d)
I tried following Queries to change format but it isn't working.
SELECT DATE_FORMAT(CURDATE(), '%d/%m/%Y') SELECT DATE_FORMAT(column_name, '%d/%m/%Y') FROM tablename
After executing this query it says rows affected and making all the values 0 000-00-00 .
This should work. I tried and works for me.
select DATE_FORMAT(birthday , '%d/%m/%Y') from event;
But what data type you have for birthday?
See this example.
尝试这个 :
SELECT DATE_FORMAT(dateColumn,'%d/%m/%Y') AS dateColumn FROM table
如果您想插入(或更新)格式不正确的日期,您可以使用
INSERT INTO `event` (columname) VALUES (STR_TO_DATE('30/09/2014', '%d/%m/%Y'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.