This is a migrated thread and some comments may be shown as answers.

Field Value Expression Problem

2 Answers 274 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tracy
Top achievements
Rank 1
Tracy asked on 20 Oct 2010, 10:04 PM
Hello,

I have an untyped data source (and no I can change it) where all my columns are strings. I have a "date" column which I would like to format specifically so I am trying to convert the field value to a date using the following:

=IIf(Fields.MinDate='', 'blank string', CDate(Fields.MinDate))

The problem is that the one record I have with a blank string as a value is erroring out on the CDate conversion, which it shouldn't because it evaluates to "true".

If I use:

=IIf(Fields.MinDate='', 'blank string', Fields.MinDate)

then the record does display 'blank string'  so I know that it is evaluating to "true" for that record.

Any ideas on how I can convert this string field to a date so I can apply special formatting (without having to write a user function)?

Thank you.

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 21 Oct 2010, 05:24 PM
Hello Tracy,

The experienced behavior is correct and by design. IIF() is a function and you need to prepare the parameters prior to executing the function as most of the programming languages work.

That's why the reporting engine first evaluates the parameters and then passes the result values to the function. What you can do is nest another IIF function inside the CDate e.g.:

=IIf(Fields.MinDate='', 'blank string', CDate(IIF(Fields.MinDate='', Now(), Fields.MinDate))

Kind regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tracy
Top achievements
Rank 1
answered on 22 Oct 2010, 06:22 PM
Thanks for the response.

I wasn't thinking of it as a function -- more of a regular IF statement in .NET.

Thanks,

Tracy

Tags
General Discussions
Asked by
Tracy
Top achievements
Rank 1
Answers by
Steve
Telerik team
Tracy
Top achievements
Rank 1
Share this question
or