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

时间:2015-03-17 16:14:24

标签: date reporting-services conditional iif ssrs-expression

我想在日期范围内做一个条件格式。因此,如果日期开始/结束范围(在参数@Begin@End中选择)在5到7天之间,则显示“周”,如果 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"

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

1 个答案:

答案 0 :(得分:0)

听起来你正在寻找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]