MySQL add 3 years to a date

It may happens if you are silly like me, that you just inserted a lot of records and then realized that you have inserted a mistaken date. In my case the date was a 3 years earlier than the required.

In order to fix it rapidly with mysql you can use the date_add function. Following a quick ad self explaining statement

update <table> set <field>=date_add(<field>,interval 3 year) where id>3289;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s