cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report Display String formula error

Former Member
0 Kudos

I've written following formula in Display String of a field, the field has value Name or Date dynamically.

if IsDate(CurrentFieldValue) then
    ToText(CDate(CurrentFieldValue), "dd MMM yyyy")
else
    CStr(CurrentFieldValue)

Following is the error I get only when field gets date value

Error in formula <Display_String>.

'if IsDate(CurrentFieldValue) then

'

A string is required here.

Accepted Solutions (1)

Accepted Solutions (1)

ido_millet
Active Contributor
0 Kudos

In the 1st branch, the field is already a date, so remove the CDate() logic.

Former Member
0 Kudos

Thanks for you attention.

Without CDate() like this it shows following design time error and if I save it forcibly the same error at run time.

Too many arguments have been given to this function.

if IsDate(CurrentFieldValue) then
    ToText(CurrentFieldValue, "dd MMM yyyy")
else
    CurrentFieldValue

I already tried different things but couldn't get rid of this problem.

If I try constant values just for testing it works, means problem is in returning value not condition.

if IsDate(CurrentFieldValue) then
    "Date"
else
    "No"

I even tried following without if and it works perfect but only for Date DB values obviously.

ToText(CDate(CurrentFieldValue), "dd MMM yyyy")

Please help me to get rid of this error, thanks in advance.

ido_millet
Active Contributor
0 Kudos

Change to:

if IsDate(CurrentFieldValue) then
    ToText(CurrentFieldValue, "dd MMM yyyy")
else
    ToText(CurrentFieldValue)

Edited by: Ido Millet on Nov 14, 2011 8:46 AM

Former Member
0 Kudos

Thanks again for your support.

I used exactly what you mentioned and I get following design time error on saving formula and it highlights the formatting parameter i.e.

"dd MMM yyyy"

.

Too many arguments have been given to this function.

and if do it with little modification as following

if IsDateTime(CurrentFieldValue) then
    (
        ToText(CDate(CurrentFieldValue), "dd MMM yyyy")
    )
else
    ToText(CurrentFieldValue)

it saves but at run time on DB date value it shows following error

A string is required here

Please help me out, thanks in advance.

Former Member
0 Kudos

Hi

Try the following :

if IsDateTime(Totext(CurrentFieldValue)) then

(

ToText(CDate(CurrentFieldValue), "dd MMM yyyy")

)

else

ToText(CurrentFieldValue)

Thanks,

Sastry

Former Member
0 Kudos

Sastry,

The same I have tried already and mentioned in post above.

Former Member
0 Kudos

Hi

I don't see that you are using the below if condition in any of your posts, try this and updated the forum what error message you are getting :

if IsDateTime(Totext(CurrentFieldValue)) then

Thanks,

Sastry

Answers (0)