Search code examples
reporting-servicesssrs-2008ssrs-2008-r2

DateDiff DateInterval


In SSRS I'm using an expression to tell me if an order was completed either before or on the day it was due to be completed.

I used:

IIF(DateDiff(DateInterval.Day, fields!date1.value, fields!date2.value) >= 0, "no", "yes")

Which works fine if there is a value in the date2 field.

However, if the order hasn't been completed, and there is no value in date2 field, then the expression returns a "yes".

Advice on how to get the expression to say "no" in this instance would be appreciated.

Thanks


Solution

  • You can check whether date2 has a value first before you compute for the datediff to avoid null result.

    IIF(IsNothing(fields!date2.value), "no", 
    IIF(DateDiff(DateInterval.Day, fields!date1.value, fields!date2.value) >= 0, "no", "yes"))