yuri1000
yuri1000

Reputation: 361

MYSql change only year from timestamp

Accidentally, my host had set the time for 2012 and in my database, there are more than 4000 records updated timestamp column as 2012-11-21 11:24:40.

I cant change time on all columns while updating, I need to keep the same time as per the table column, I just need to change only year 2012 to 2016 in that table.

I listed all columns using this query,

SELECT * FROM `table` WHERE `del_date` LIKE '%2012-11-21%';

but do not know to change the year only in that column.

Please help how can I change the same.

Upvotes: 1

Views: 1494

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

You can use ADDDATE(), like

UPDATE yourTableName SET del_date = ADDDATE(del_date, INTERVAL 4 YEAR);

Upvotes: 2

Related Questions