opLastTurn and TurnTime are DateTime Columns of mytable
SELECT ADDTIME(opLastTurn,TurnTime) AS result FROM mytable;
but it returns Null,what is wrong?
opLastTurn and TurnTime are DateTime Columns of mytable
SELECT ADDTIME(opLastTurn,TurnTime) AS result FROM mytable;
but it returns Null,what is wrong?
The first argument must be a datetime expression. The second must be a time expression. If they can't be parsed that way, the function gives up and returns NULL.
WRONG: Both arguments are datetime.
mysql> select addtime('2017-08-17 11:00:00', '2017-08-17 11:00:00');
+-------------------------------------------------------+
| addtime('2017-08-17 11:00:00', '2017-08-17 11:00:00') |
+-------------------------------------------------------+
| NULL |
+-------------------------------------------------------+
RIGHT: Second argument is time:
mysql> select addtime('2017-08-17 11:00:00', '11:00:00');
+--------------------------------------------+
| addtime('2017-08-17 11:00:00', '11:00:00') |
+--------------------------------------------+
| 2017-08-17 22:00:00 |
+--------------------------------------------+
The second arguments should be a time .. so try using
SELECT ADDTIME(opLastTurn, time(TurnTime) ) AS result FROM mytable;