Tuesday, March 20, 2012

Compound IIF Statement

The compound statement:
=Iif(DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) > 30 &
DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) < 61,
Fields!Amount.Value, "")
The purpose of the above statement is to print the "Amount.Value" if the #
of days is greater than 30 and less than 61. The problem is that it prints
the value "Amount.Value" and ignores the actual # of days. IE, if the
difference in the dates is 15, "Amount.Value" is printed. Is this syntax
correct? Can you have compound statements using DateDiff?
Thanks,
JohnYou are using & instead of AND. & is appending the two values together
instead of doing a boolean compare.
Oh, you can definitely have compound iif statements but you are not doing
that. A compound iif would be iif(some boolean expression, true value,
iif(blah, blah, blah))
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"John Joslin" <JohnJoslin@.discussions.microsoft.com> wrote in message
news:945474CD-1373-43E4-AD35-01DBCF3671FF@.microsoft.com...
> The compound statement:
> =Iif(DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) > 30 &
> DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) < 61,
> Fields!Amount.Value, "")
> The purpose of the above statement is to print the "Amount.Value" if the #
> of days is greater than 30 and less than 61. The problem is that it prints
> the value "Amount.Value" and ignores the actual # of days. IE, if the
> difference in the dates is 15, "Amount.Value" is printed. Is this syntax
> correct? Can you have compound statements using DateDiff?
> Thanks,
> John|||Thanks Bruce! It works very nicely now...
"Bruce L-C [MVP]" wrote:
> You are using & instead of AND. & is appending the two values together
> instead of doing a boolean compare.
> Oh, you can definitely have compound iif statements but you are not doing
> that. A compound iif would be iif(some boolean expression, true value,
> iif(blah, blah, blah))
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "John Joslin" <JohnJoslin@.discussions.microsoft.com> wrote in message
> news:945474CD-1373-43E4-AD35-01DBCF3671FF@.microsoft.com...
> > The compound statement:
> >
> > =Iif(DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) > 30 &
> > DateDiff("d", Fields!TranDate.Value, Parameters!AgeDate.Value) < 61,
> > Fields!Amount.Value, "")
> >
> > The purpose of the above statement is to print the "Amount.Value" if the #
> > of days is greater than 30 and less than 61. The problem is that it prints
> > the value "Amount.Value" and ignores the actual # of days. IE, if the
> > difference in the dates is 15, "Amount.Value" is printed. Is this syntax
> > correct? Can you have compound statements using DateDiff?
> >
> > Thanks,
> >
> > John
>
>

No comments:

Post a Comment