用于条件日期格式 (BETWEEN) 的 SSRS IIF 语句表达式

SSRS IIF statements expressions for conditional date formatting (BETWEEN)

我想对日期范围进行条件格式设置。所以如果日期begin/end范围(在参数@Begin@End中选择)在5到7天之间,显示"week",如果between 28 days and 31 days,显示"Month",其他一切,显示"X days",等等

我有这样的东西,但在语法上无法计算。我正在努力解决这个问题,所以任何人都可以帮助我或指出正确的方向吗?

我有的例子;

=Iif(Parameters!DateBegin.Value = today() AND Parameters!DateEnd.Value = Today(), "Today", Iif(Parameters!DateBegin.Value = DateAdd("d",-1,Today()) AND Parameters!DateEnd.Value = Today(), "Yesterday", Iif(Parameters!DateBegin.Value AND Parameters!DateEnd.Value *difference is BETWEEN 5-7 days*, "Week", Iif(Parameters!DateBegin.Value AND Parameters!DateEnd.Value *difference is BETWEEN 28-31 days*, "Month", Everything else = *difference BETWEEN* Parameters!DateBegin.Value AND Parameters!DateEnd.Value & "days"

我该如何实现这一目标? :)

听起来您正在寻找 DATEDIFF() 函数。

例如(5-7天):

Iif(
(DateDiff("d", Parameters!DateBegin.Value, Parameters!DateEnd.Value) > 4) AND (DateDiff("d", Parameters!DateBegin.Value, Parameters!DateEnd.Value) < 8), "Week", [etc]