问题描述
我有两列:beginTime和duration。我正在计算endTime。问题是我得到了空的结果。我尝试过几件事。
code> DATE_ADD(startTime,INTERVAL`duration` MINUTE)AS endTime
DATE_ADD(startTime,INTERVAL'10'MINUTE)AS endTime
DATE_ADD(startTime,INTERVAL 10分钟)AS endTime
但每次结果为空。 startTime不为空。它是09:00:00格式的时间字段。
任何人都可以帮助我吗?
DATE_ADD
将返回 NULL
如果时间格式不正确,以及警告:
mysql> \W
显示警告启用。
mysql> SELECT DATE_ADD('25:00:00',INTERVAL 10 MINUTE)AS endTime
- > ;
+ --------- +
| endTime |
+ --------- +
| NULL |
+ --------- +
1行集,1警告(0.00秒)
警告(代码1292):日期时间值不正确:'25 :00:00'
另请注意,'hh:mm:ss'
不是正确的datetime格式。你需要有年,月和日。
你可以在 MySQL
中启用警告,然后重复查询与您的数据?
I have two columns: beginTime and duration. I'm trying to calculate the endTime. The problem is that i get empty results back.
I have tried several things.
DATE_ADD(startTime, INTERVAL `duration` MINUTE) AS endTime
DATE_ADD(startTime, INTERVAL '10' MINUTE) AS endTime
DATE_ADD(startTime, INTERVAL 10 MINUTE) AS endTime
But everytime the result is empty. startTime is not empty. It is a time field in the format 09:00:00.
Can anyone help me with this?
DATE_ADD
will return NULL
if the time format is incorrect, along with a warning:
mysql> \W
Show warnings enabled.
mysql> SELECT DATE_ADD('25:00:00', INTERVAL 10 MINUTE) AS endTime
-> ;
+---------+
| endTime |
+---------+
| NULL |
+---------+
1 row in set, 1 warning (0.00 sec)
Warning (Code 1292): Incorrect datetime value: '25:00:00'
Also note that 'hh:mm:ss'
is not a correct datetime format. You need to have year, month and day also.
Could you please enable warnings in MySQL
and repeat the query with your data?
这篇关于MySQL DATE_ADD不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!