在SSRS中使用除法时出现错误

时间:2019-01-07 06:37:58

标签: reporting-services ssrs-2012

在SSRS 2017中使用此公式时出现错误:

  

没有为类型'integer'和'System.TimeSpan'定义运算符'/'

     

未为类型'System.TimeSpan'和'System.TimeSpan'定义运算符'*'

=IIF(
     100 / (DateAdd("d", -(Day(Today)), Today) - 
            DateSerial(Year(DateAdd("m", -1, Now())),  1, 1)
            )
     * ((Today - DateSerial(Year(DateAdd("m", -1, Now())),  1, 1)) / 100) > 1, 
     1, 
     100 / (DateAdd("d",-(Day(Today)), Today) - 
            DateSerial(Year(DateAdd("m", -1, Now())),  1, 1)
            )
     * ((Today - DateSerial(Year(DateAdd("m", -1, Now())),  1, 1)) / 100)
     )

1 个答案:

答案 0 :(得分:0)

使用DateDiff()代替-

=IIF(
 100 / DateDiff("d", DateAdd("d", -Day(Today), Today),
                DateSerial(Year(DateAdd("m", -1, Now())),  1, 1)
                )
 * (DateDiff("d", Today, DateSerial(Year(DateAdd("m", -1, Now())),  1, 1)) / 100) > 1, 
 1, 
 100 / DateDiff("d", DateAdd("d",-(Day(Today)), Today), 
                DateSerial(Year(DateAdd("m", -1, Now())),  1, 1)
                )
 * DateDiff("d", Today, DateSerial(Year(DateAdd("m", -1, Now())),  1, 1)) / 100
 )