Problem with IIF in SSRS

  • I have the following expression in my SSRS report:

    = IIf(IsNothing(Fields!Drop_Off_Time.Value), (TimeValue(Fields!Actual_Arrive_Time.Value) - TimeValue(Fields!Pickup_Time.Value)), CInt(0))

    The value when Fields!Drop_Off_Time.Value is not null performs the correct calculation. The value however when Fields!Drop_Off_Time.Value is null

    consistently returns the value #Error in the field.

    Any ideas are welcome.

    Thanks:crazy:

  • Both results from an IIF statement must be the same. By the look of your code the .Value items are probably datetime fields. You could try changing the cint(0) to cast('01/01/1900 00:00:00' as datetime). the cast statement creates a datetime of 12am on the 01/01/1900 which I think equates to as small a datetime as you can store as it's the date all other dates are calculated from.

    I hope this helps.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply