Jump to content

Archived

This topic is now archived and is closed to further replies.

eranwein

*SOLVED* date update

Recommended Posts

how do i increment a record field which is a type of datetime to be it's initial value plus let's say one year.

i want to use one UPDATE query, and not SELECT and then UPDATE.

for example '2004-11-15 10:11:48' will be 2005-11-15 10:11:48.

Share this post


Link to post
Share on other sites
Example:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] table_name SET date_column_name [color=orange]=[/color] DATE_ADD(date_column_name, INTERVAL 1 YEAR) [color=green]WHERE[/color] ...
[!--sql2--][/div][!--sql3--]

Leave out the "WHERE" condition to update all rows in the table.

See:
[a href=\"http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#id3216476\" target=\"_blank\"]http://dev.mysql.com/doc/refman/4.1/en/dat....html#id3216476[/a]

[a href=\"http://dev.mysql.com/doc/refman/4.1/en/update.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/4.1/en/update.html[/a]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.