add a year to existing date and update all records

I am trying to figure out how to take all the current dates in the field called dateCreated in the table clientRecords then add a year to dateCreated and update the field dateExpired in mySQL
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

-- firstly, backup the table
insert into clientRecords_bck select * from clientRecords;

-- then update value of dateExpired field, +3 years for example
update clientRecords set dateExpired=dateCreated+interval 3 year
nemws1Database AdministratorCommented:
Not sure why gnoon is adding *three* years.  But yes, back up your data, as always, although I usually use 'mysqldump' instead of creating another table:
mysqldump dbname clientRecords > clientRecords.sql

Open in new window

And then use UPDATE and DATE_ADD to add one year:
UPDATE clientRecords
SET dateExpired=DATE_ADD(dateCreated, INTERVAL 1 YEAR)

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.