eranwein Posted April 4, 2006 Share Posted April 4, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6610-solved-date-update/ Share on other sites More sharing options...
toplay Posted April 5, 2006 Share Posted April 5, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/6610-solved-date-update/#findComment-24039 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.