dave_8 Posted November 28, 2013 Share Posted November 28, 2013 Hi, I'm trying to get a formatted date into a Jaspersoft Studio Report expression. Some of my data has nulls and some has date completed.I can identify which elements are null and which have dates with an expression likeIF(EQUALS($F{adate},null),"N/A",$F{adate})but if I try and format the date:IF(EQUALS($F{adate},null),"N/A",DATEFORMAT($F{adate},"dd-MMM-YYYY"))I get an error when filling the report (see below)Any ideas how to work around this - I'm driving myself mad !Thanks in advance I hope ! Dave net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : IF(EQUALS($F{support expires},null),"N/A",DATEFORMAT($F{support expires},"dd-MMM-YYYY"))at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:482)at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$18(ReportControler.java:457)at com.jaspersoft.studio.editor.preview.view.control.ReportControler$4.run(ReportControler.java:347)at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : IF(EQUALS($F{support expires},null),"N/A",DATEFORMAT($F{support expires},"dd-MMM-YYYY"))at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:244)at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1016)at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:504)at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:488)at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259)at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:456)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2057)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:778)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:288)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151)at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:932)at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFiller.run(BaseFillHandle.java:120)at java.lang.Thread.run(Thread.java:695)Caused by: groovy.lang.MissingMethodException: No signature of method: net.sf.jasperreports.functions.standard.DateTimeFunctions.DATEFORMAT() is applicable for argument types: (java.lang.String, java.lang.String) values: [2013-11-07, dd-MMM-YYYY]Possible solutions: DATEFORMAT(java.util.Date, java.lang.String)at net.sf.jasperreports.compilers.GroovyEvaluator.functionCall(GroovyEvaluator.java:120)at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:272)at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52)at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:57)at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)at Renewals28Nov_1385649853078_751931.methodMissing(calculator_Renewals28Nov_1385649853078_751931:22)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:832)at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1123)at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1076)at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:904)at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)at Renewals28Nov_1385649853078_751931.evaluate(calculator_Renewals28Nov_1385649853078_751931:356)at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:231)... 14 more Link to comment Share on other sites More sharing options...
angel.goitia Posted December 10, 2013 Share Posted December 10, 2013 In your error trace I can see".DATEFORMAT() is applicable for argument types: (java.lang.String, java.lang.String)"The first argument you are passing to DATEFORMAT is an String and it expects a Date... Just convert your string date to date using, for example, DATE().Hope I'm not late.Regards,Angel. Link to comment Share on other sites More sharing options...
dave_8 Posted December 10, 2013 Author Share Posted December 10, 2013 you are right - thank you Link to comment Share on other sites More sharing options...
dave_8 Posted December 11, 2013 Author Share Posted December 11, 2013 in fact I had Jaspersoft studio taking a SQL date and using it as a string - caught out by data typing ! thank you again Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now