如何将时差转换为 SSrs 中的数字

问题描述 投票:0回答:1

我正在尝试获取计算员工上下班时间差的代码。

在我输入的表达式 (=Fields!Punched_Out.Value-Fields!Punched_In.Value) 中,这给了我差异,但是数据采用时间格式,例如 2:30:00。

如何将 2:30:0 转换为数字,例如 2.5

谢谢 萨米

将时间转换为数字

time reporting-services numbers
1个回答
0
投票

使用

DATEDIFF()
计算分钟数、秒数或您需要的精确度,然后转换为小时(我假设)。

例如

=DATEDIFF("n", Fields!Punched_In.Value, Fields!Punched_Out.Value)/60 

在这种情况下,“n”得到以分钟为单位的差异,然后将其除以 60 即可得到小时。您可以使用文本框中的格式表达式格式化输出以舍入值。

MS 文档:https://learn.microsoft.com/en-us/sql/integration-services/expressions/datediff-ssis-expression?view=sql-server-ver16

© www.soinside.com 2019 - 2024. All rights reserved.