asvasdv asdvsadvs
asvasdv asdvsadvs

Reputation: 113

MySQL - Update date/time - 10 mins. in future

Is it possible to update date/time in MySQL directly.

UPDATE tasks SET date_due='2014-12-01 10:30:00' WHERE  tasks.id = '97534f55-32a9-8ef3-2e2f-547c3782d5e6' AND deleted=0;

I need to update time, 10 mins. in future.

The said time is not current time therefore I cannot use DATE_ADD(NOW()

Thanx

Upvotes: 0

Views: 355

Answers (1)

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44844

You can use date_add() on a datetime value not just now()

mysql> select date_add('2014-12-01 10:30:00',interval 10 minute) as date ;
+---------------------+
| date                |
+---------------------+
| 2014-12-01 10:40:00 |
+---------------------+
1 row in set (0.00 sec)

So it will be

UPDATE 
tasks 
SET date_due=date_add(date_due,interval 10 minute) 
WHERE  tasks.id = '97534f55-32a9-8ef3-2e2f-547c3782d5e6' 
AND deleted=0;

Upvotes: 1

Related Questions