简体   繁体   English

在SSRS中,DateDiff的否定结果为0

[英]DateDiff negative results to 0 in SSRS

I'm trying to set my results for an expression in SSRS to return 0 if the datediff results is negative. 我正在尝试将datediff结果为负的SSRS中的表达式的结果设置为返回0。 my expression is: 我的表情是:

=DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.value) = DateDiff(DateInterval.Minute,字段!Check_In_Time.Value,字段!Date ___ Time.value)

and tried: 并尝试:

=Max(0,(DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.value))) --this one errors and doesn't run = Max(0,(DateDiff(DateInterval.Minute,Fields!Check_In_Time.Value,Fields!Date ___ Time.value)))-这一个错误并且无法运行

but some results are negative, I want it to return a 0 if it's negative. 但有些结果是负数,如果它为负数,我希望它返回0。 Can anyone help? 有人可以帮忙吗?

This actually worked for me: 这实际上为我工作:

=IIF(DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.Value) <= 0, nothing, DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.Value)) = IIF(DateDiff(DateInterval.Minute,Fields!Check_In_Time.Value,Fields!Date ___ Time.Value)<= 0,无,DateDiff(DateInterval.Minute,Fields!Check_In_Time.Value,Fields!Date ___ Time.Value))

Unfortunately, there's no function to do this in SSRS. 不幸的是,SSRS中没有执行此操作的功能。

You'd just need to use an IIF to check for it and use 0 if the Date_Time was before the Check_In_Time . 你只需要使用一个IIF检查,并使用0,如果Date_Time是前Check_In_Time

=IIF(Check_In_Time > Date_Time, 0, DateDiff(DateInterval.Minute, Fields!Check_In_Time.Value, Fields!Date___Time.value))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM