I want to add x days to a datetime
Posted 10 February 2006 - 03:51 PM
There is another field in the DB called 'days' which is the no of days that the trial will run for.
I want another field, called 'trial_end' which is, you've guessed it, the 'trial_start' plus the number of days.
I am struggling as to what syntax to use, to calculate the 'trial_end' value. I assume I need to turn the days into seconds and add them onto the timestamp of the trial_start.
Can anyone help please as I'm struggling. Thanks
Posted 10 February 2006 - 07:50 PM
Anyway, regardless, you can always use INTERVAL to set it (UNTESTED):
UPDATE yourTable SET trial_end = trial_start + INTERVAL days DAY WHERE....
Hope that helps.
Posted 10 February 2006 - 07:58 PM
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] tableName SET trial_end = DATE_ADD(trial_start, INTERVAL days DAY);
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users