简体   繁体   中英

IIF and Date logic and format for SSRS

I have the following code

=IIF(Month(Fields!effectivedate.Value) <> Month(Now()), Now(), Fields!effectdate.Value)

In this code I check to see if Fields!effectivedate.Value is the current month.

  • If it is the current month then it displays Fields!effectivedate.Value .
  • If it is not the current month then it displays the current date.

In addition to doing this check I would like to check for another value, fields!Freeze.Value

Here is how it would look in VB.NET code

If fields!Freeze.Value = true
     Fields!effectdate.Value
else
     IIF(Month(Fields!effectivedate.Value) <> Month(Now()), Now(), Fields!effectdate.Value)
end if

How would I write this in SSRS code?

Please ask for further clarification if i have failed to explain something properly.

只需嵌套IIfs:

=IIf(Fields!Freeze.Value, Fields!effectdate.Value, IIF(Month(Fields!effectivedate.Value) <> Month(Now()), Now(), Fields!effectdate.Value))

You will need to use a nested IIf function as started by @lc. however you need to be more clear what you want to check for in the Freeze field.

For example you can check for blanks using the IsNothing() function, or if its a booleon you may need to see if Fields!Freeze.Value = 1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM