Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS trouble using DateDiff in a IIF statement

SSRS returns an #error when the statement is False, but No Start Date when the statement is True. I tested and the DateDiff is correct in the False side of the statement. I'm not sure which direction to go from here. Thank you.

=IIF(Fields!JobOrderIssueDate.Value = "", "No Start Date",DateDiff("d",Today(),Fields!ProjectedConstEndDate.Value))
like image 941
PanczerTank Avatar asked Feb 26 '26 08:02

PanczerTank


1 Answers

You are mixing data types in your IIF returning either a STRING or a DATE depending on the condition of the IIF. This is not going to work.

One approach would be to convert the data type returned by the FALSE condition so that it is also returns a STRING (using CStr()):

=IIF(Fields!JobOrderIssueDate.Value = "", "No Start Date",CStr( DateDiff("d",Today(),Fields!ProjectedConstEndDate.Value)))

or you could gain a little more control over formatting (using FormatDateTime()):

=IIF(Fields!JobOrderIssueDate.Value = "", "No Start Date",FormatDateTime( DateDiff("d",Today(),Fields!ProjectedConstEndDate.Value), DateFormat.ShortDate)) 
like image 132
David Tansey Avatar answered Mar 02 '26 14:03

David Tansey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!