SSRS表达式仅在日期字段中显示年份和月份

时间:2014-07-29 12:07:31

标签: reporting-services ssrs-2008 ssrs-grouping

如何在SSRS中构建仅捕获月份和年份的表达式,而不是从日期戳记字段中捕获日期?

我正在尝试在SSRS中创建Month To Date列。我有一个日期时间戳字段,我还创建了一个Month字段和一个Year字段,希望能解决我自己的问题。我没有。

我有一个表达式,允许我捕捉月份并且它有效,但在我的数据集中,我有2013年和2014年的7月数据。这个表达式我只想捕获2014年。

=Count(IIF(Fields!Date_Month.Value = Month(Today()), Fields!AcctNo.Value, Nothing), 
"Eligibility")

我得到了本年度的工作:

=Count(IIF(Fields!Year.Value = Year(Today()), Fields!AcctNo.Value, Nothing), 
"Eligibility")

我可以以某种方式结合2个表达式吗?我应该吗?

Orrrrrrrrrr

我试图将我的日期戳字段用于无法使用:我因为这种憎恶而得到#Error

=Count(IIF(Fields!Datestamp.Value = Month(Today()), Fields!AcctNo.Value, 
Nothing),   "Eligibility")

我认为首选的方法是使用我的上述日期戳字段并解析月份和年份。这就是我做的方式....如果我知道如何实际做到这一点。

1 个答案:

答案 0 :(得分:1)

正如您所建议的那样,您可以将两个表达式结合起来,通过一些小改动来获得所需的结果:

=Count(IIf(Year(Fields!Datestamp.Value) = Year(Today)
      and Month(Fields!Datestamp.Value) = Month(Today)
    , Fields!AcctNo.Value
    , Nothing)
  , "Eligibility")

这将计算数据集中与当前日期具有相同年份和月份的所有行。

相关问题