Link to home
Start Free TrialLog in
Avatar of digitalwise
digitalwise

asked on

ColdFusion Report Builder

I am trying to use CF Report Builder because the client needs a pretty nicely broken out PDF report.    If I could just get it to output the data, it is going to be VERY pretty.    The code in the current HTML report is

<CFIF isdate(primaryreviewerdate)>#val(datediff("d", PrimaryReviewerDate, now()))#<CFELSE>0</CFIF> Days

Open in new window


This is my translation.  

iif(isdate(query.PrimaryReviewerDate), DateDiff(d, query.PrimaryReviewerDate, getdate()), DE("0 Days"))

Open in new window


Getting the error:   If the expression is a string, ensure that it is within quotes. Error: iif(isdate(query.PrimaryReviewerDate), DateDiff(d, query.PrimaryReviewerDate, getdate()), DE("0 Days")) is not a valid ColdFusion expression.

Anyone have any ideas??
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

Look at the working example. I simulated the query data, using QueryNew.
<cfscript>
            query = QueryNew("ID,PrimaryReviewerDate","integer,varchar");
            tt = QueryAddRow(query, 1);
            tt = QuerySetCell(query, "ID", 1);
            tt = QuerySetCell(query, "PrimaryReviewerDate", "12/1/2014");
            value2=iif((isdefined ("query.PrimaryReviewerDate") && isdate(query.PrimaryReviewerDate)), DateDiff('d',query.PrimaryReviewerDate, Now()), "O days");            
            WriteOutput ("Diff is :" &  value2);
</cfscript>

What kind of data field is PrimaryReviewerDate in your query ?
I checked with Date field also. It should work

query = QueryNew("ID,PrimaryReviewerDate","integer,date");
            tt = QueryAddRow(query, 1);
            tt = QuerySetCell(query, "ID", 1);
            tt = QuerySetCell(query, "PrimaryReviewerDate", CreateDateTime(2014,9,24,12,1,0));
            value2=iif((isdefined ("query.PrimaryReviewerDate") && isdate(query.PrimaryReviewerDate)), DateDiff('d',query.PrimaryReviewerDate, Now()), DE("O days"));            
            WriteOutput ("Diff is :" &  value2);
Avatar of digitalwise
digitalwise

ASKER

This is in CF Report Builder.   That doesn't work.  I get the same error.
try

value2=iif((isdefined ('query.PrimaryReviewerDate') && isdate(query.PrimaryReviewerDate)), DateDiff('d',query.PrimaryReviewerDate, Now()),'O days');
Single Quote in lieu of Double quote
ASKER CERTIFIED SOLUTION
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks.