I want to do a conditional format on date ranges. So if the date begin/end range (selected in the parameters @Begin
and @End
) is between 5 and 7 days, display "week", if between 28 days and 31 days
, display "Month"
, everything else, show "X days"
, etc.
I have something like this, but syntactically doesn't compute. I'm struggling with this one so can anyone help or point me in the right direction?
Example of what I have;
=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"
How do I go about achieving this? :)
It sounds like you're looking for the DATEDIFF()
function.
For example(5-7 days):
Iif(
(DateDiff("d", Parameters!DateBegin.Value, Parameters!DateEnd.Value) > 4) AND (DateDiff("d", Parameters!DateBegin.Value, Parameters!DateEnd.Value) < 8), "Week", [etc]