Comments - ADDTIME

8 years, 1 month ago Stephen Alexander

Argument need not be in string format; a numeric argument will be applied just as well.

MariaDB [(none)]> select addtime(now(),-400),now();
+---------------------+---------------------+
| addtime(now(),-400) | now()               |
+---------------------+---------------------+
| 2016-02-21 22:20:55 | 2016-02-21 22:24:55 |
+---------------------+---------------------+
 
4 years, 3 months ago Christoph Brändle

This works, but might be not what you expect.

For example, addtime(now(),12345) will add one hour, 23 minutes and 45 seconds to the current time, not 12345 seconds.

In the example above, 4 minutes are subtracted from the current time, not 400 seconds.

addtime(now(),99) will return null.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.