1

Any idea why getting an #Error using the code below when the field fp_firstshifttimein does not contain value. But when the field contains value, it works.

=IIF(IsDate(Fields!fp_firstshifttimein.Value), 
DateTime.Parse(Fields!fp_firstshifttimein.Value).addDays(8), Nothing)

Same issue with the code below:

=IIF(IsNothing(Fields!fp_firstshifttimein.Value), Nothing,
 DateTime.Parse(Fields!fp_firstshifttimein.Value).addDays(8))

Thanks all.

Sam
  • 2,935
  • 1
  • 19
  • 26
dalday
  • 31
  • 1
  • 6

3 Answers3

2

I found out that SSRS evaluates each part of the function before the report is executed. I tried the code below. It worked.

=IIF(IsDate(Fields!fp_firstshifttimein.Value),
DateTime.Parse(iif(IsDate(Fields!fp_firstshifttimein.Value) ="1",
Fields!fp_firstshifttimein.Value,"01/01/1900")).addDays(8), nothing)
Andy K
  • 4,944
  • 10
  • 53
  • 82
dalday
  • 31
  • 1
  • 6
1

Can you have a try with this?

=IIF(Fields!fp_firstshifttimein.Value is nothing, nothing, DateTime.Parse(Fields!fp_firstshifttimein.Value).addDays(8))

Andy K
  • 4,944
  • 10
  • 53
  • 82
0

Use the DateAdd function like this:

=IIF(IsNothing(Fields!fp_firstshifttimein.Value), Nothing,
    DateAdd("d", 8, Fields!fp_firstshifttimein.Value))
StevenWhite
  • 5,907
  • 3
  • 21
  • 46