ColdFusion Report Builder

digitalwise
digitalwise used Ask the Experts™
on
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??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Commented:
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 ?
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Commented:
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);

Author

Commented:
This is in CF Report Builder.   That doesn't work.  I get the same error.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Commented:
try

value2=iif((isdefined ('query.PrimaryReviewerDate') && isdate(query.PrimaryReviewerDate)), DateDiff('d',query.PrimaryReviewerDate, Now()),'O days');
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Commented:
Single Quote in lieu of Double quote
Principal Systems Engineer
Top Expert 2005
Commented:
Okay. I tried with CF Builder for CF 9

Following worked for me

iif (isDate(query.PrimaryReviewerDate) EQ true, DateDiff('d',query.PrimaryReviewerDate, Now()),DE("0 Days"))
Pravin AsarPrincipal Systems Engineer
Top Expert 2005

Commented:
thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial