SSRS IIF Date evaluation

和自甴很熟 提交于 2019-12-04 12:37:22

As I understand the requirement, you'll need to add another IIf() section which checks the difference in days between the two dates, then displays effectiveDate if the difference is < 30 days:

=IIf
(
  Fields!Freeze.Value
  , IIF
  (
    DateDiff(DateInterval.Day, Fields!effectiveDate.Value, Fields!FreezeDate.Value) < 30
    , Fields!effectiveDate.Value
    , Fields!FreezeDate.Value
  )
  , IIF
  (
    Month(Fields!effectivedate.Value) <> Month(Now())
    , Format(Now(), “MM/dd/yyyy”)
    , Fields!effectivedate.Value
  )
)

I suspect the thing you're missing is knowledge of the DATEDIFF function.

http://msdn.microsoft.com/en-us/library/aa337092%28v=sql.90%29.aspx

IIF(
  DATEDIFF(DAY, Fields!FreezeDate.Value, Fields!effectiveDate.Value) => 30,
  Fields!FreezeDate.Value, 
  Fields!effectiveDate.Value )

Above, we're using DATEDIFF.

First parameter is the Time measurement we want to measure differences between. DAY.

Example:-

DATEDIFF(DAY, '2013-01-01', '2013-01-15') should yield 14.

Tying it all up, we're calculating the day difference between FreezeDate and effectiveDate. When that value is over 30, display the effectiveDate. Otherwise, display FreezeDate.

You may need to play around to get the desired result. Your English description of your logic was not great. Did the best I could under the circumstances.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!