Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.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
如何在SQLServer2008R2中减去时间_Sql_Sql Server_Sql Server 2008 R2 - Fatal编程技术网

如何在SQLServer2008R2中减去时间

如何在SQLServer2008R2中减去时间,sql,sql-server,sql-server-2008-r2,Sql,Sql Server,Sql Server 2008 R2,我想从数据库中选择一个时间范围以获取该时间范围 如果说员工的起始时间是12:00,范围是11:45到12:15,但我需要计算它,我可以加,但不能减 我的代码 select DATEDIFF(MINUTE, 15, Starttime) from Employees where EmployeeID = 18 select DATEADD(MINUTE, 15, Starttime) from Employees where EmployeeID = 18 select Employe

我想从数据库中选择一个时间范围以获取该时间范围

如果说员工的起始时间是12:00,范围是11:45到12:15,但我需要计算它,我可以加,但不能减

我的代码

select DATEDIFF(MINUTE, 15, Starttime) 
from Employees 
where EmployeeID = 18

select DATEADD(MINUTE, 15, Starttime) 
from Employees 
where EmployeeID = 18

select EmployeeID, StartTime, ReturnTime 
from Employees 
where EmployeeID = 18
结果

但我想要的是:

而不是-20868-
11:57:12:0000000


比如当我加上12:12:12=12:27:12时会发生什么,这就是你想要的吗

select DATEADD(MINUTE,-15,Starttime) from Employees where EmployeeID = 18