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??
ColdFusion Language

Avatar of undefined
Last Comment
Pravin Asar

8/22/2022 - Mon
Pravin Asar

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 Asar

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);
digitalwise

ASKER
This is in CF Report Builder.   That doesn't work.  I get the same error.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Pravin Asar

try

value2=iif((isdefined ('query.PrimaryReviewerDate') && isdate(query.PrimaryReviewerDate)), DateDiff('d',query.PrimaryReviewerDate, Now()),'O days');
Pravin Asar

Single Quote in lieu of Double quote
ASKER CERTIFIED SOLUTION
Pravin Asar

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Pravin Asar

thanks.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.