Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL中的更新时间到日期时间列_Mysql_Sql - Fatal编程技术网

MySQL中的更新时间到日期时间列

MySQL中的更新时间到日期时间列,mysql,sql,Mysql,Sql,我忘记了在PHP代码中更改时区,现在数据库已经保存了伦敦时区的时间。所以我想更新我的专栏;s仅限时间(非日期)。我在mysql中有一列dateTime。我只想在时间上加上5个小时。 这是怎么可能的。我尝试了以下SQL,但它不起作用: update tblswitchemprequest set time(responseDateTime)+5 你可以用 您的查询应该如下所示 update tblswitchemprequest set responseDateTime = DATEADD(h

我忘记了在PHP代码中更改时区,现在数据库已经保存了伦敦时区的时间。所以我想更新我的专栏;s仅限时间(非日期)。我在mysql中有一列dateTime。我只想在时间上加上5个小时。 这是怎么可能的。我尝试了以下SQL,但它不起作用:

update 
tblswitchemprequest
set time(responseDateTime)+5
你可以用

您的查询应该如下所示

update tblswitchemprequest set responseDateTime = DATEADD(hh, 5, responseDateTime)

使用
DATE\u ADD
,它需要两个参数,第一个是初始日期时间,第二个参数包括关键字
INTERVAL
、要添加的数量和要添加的数量单位

在您的情况下,源时间将是
响应时间
,第二个参数将是
间隔5小时
。它返回更新的日期时间

UPDATE tblswitchemprequest SET responseDateTime = DATE_ADD(responseDateTime, INTERVAL 5 HOUR)

功能ttl_employee_switch.DATEADD不存在日期tblswitchemprequest SET responseDateTime=responseDateTime+间隔5小时
UPDATE tblswitchemprequest SET responseDateTime = DATE_ADD(responseDateTime, INTERVAL 5 HOUR)