计算 2 个表和列之间的时间差,数据类型为 smalldatetime 和 time
calculate difference between time from 2 tables and column have datatype as smalldatetime and time
我有 2 个 table 班。
Shift table 就像
Starttime | Endtime | shift |
---------------------------------------------------------
07:00:00.00 | 16:00:00.00 | 1 |
在table就像
In | Out | shift |
------------------------------------------------------------
2016-07-01 06:54:00 | 2016-07-01 17:03:00 | 1 |
我想计算开始时间和结束时间之间的差异,例如
Output
------
01.03
01.03是结束时间和结束时间的时间差
我想在 SSRS 中执行此操作,但在输出字段中执行此操作时出现错误
=Fields!out.Value-Fields!endtime.Value
我们可以使用 SQL 查询吗?
Endtime
数据类型是时间并且 out
数据类型是 smalldatetime
根据您提供的 table 结构,在您的 SQL 查询中使用 (Out-Endtime) 来计算所需的差异,您的查询应该如下所示:
SELECT *,CONVERT(VARCHAR(10),(Out-Endtime),108)DIFF FROM tblIN I JOIN tblShift S ON I.shift=S.shift
结果
Starttime Endtime shift In Out shift DIFF
07:00:00.0000000 16:00:00.0000000 1 2016-07-01 06:54:00 2016-07-01 17:03:00 1 01:03:00
我有 2 个 table 班。 Shift table 就像
Starttime | Endtime | shift |
---------------------------------------------------------
07:00:00.00 | 16:00:00.00 | 1 |
在table就像
In | Out | shift |
------------------------------------------------------------
2016-07-01 06:54:00 | 2016-07-01 17:03:00 | 1 |
我想计算开始时间和结束时间之间的差异,例如
Output
------
01.03
01.03是结束时间和结束时间的时间差
我想在 SSRS 中执行此操作,但在输出字段中执行此操作时出现错误
=Fields!out.Value-Fields!endtime.Value
我们可以使用 SQL 查询吗?
Endtime
数据类型是时间并且 out
数据类型是 smalldatetime
根据您提供的 table 结构,在您的 SQL 查询中使用 (Out-Endtime) 来计算所需的差异,您的查询应该如下所示:
SELECT *,CONVERT(VARCHAR(10),(Out-Endtime),108)DIFF FROM tblIN I JOIN tblShift S ON I.shift=S.shift
结果
Starttime Endtime shift In Out shift DIFF
07:00:00.0000000 16:00:00.0000000 1 2016-07-01 06:54:00 2016-07-01 17:03:00 1 01:03:00