Jump to content
Changes to the Jaspersoft community edition download ×

Days function working in Jaspersoft Studio but not with ReportServer


siick
Go to solution Solved by reportdev,

Recommended Posts

Hello everybody!

I hace few reports which are using the function DAYS(DATE1, DATE2) to calculate number of days between two dates.

My expression is (DAYS(new SimpleDateFormat("dd/MM/yyyy").parse($F{DATE_DEBUT_ABSENCE}),new SimpleDateFormat("dd/MM/yyyy").parse($V{date_fin_sejour}))+1).

It's working well and without error on Jaspersoft studio 6.4.0 but when i try to generate a report with jasperreports 6.2.0 i have an error.

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: (DAYS(new SimpleDateFormat("dd/MM/yyyy").parse($F{DATE_DEBUT_ABSENCE}),new SimpleDateFormat("dd/MM/yyyy").parse($V{date_fin_sejour}))+1)

How an expression can work on Jaspersoft Studio and not on jasperreports? Thanks in advance for your future answer.

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Hi there,

just a quick info. Even I got the same error when used on jasperreports api, but it works fine on Jasper Server and Studio.

I believe jasperreports api jar does not have all the Jasper Server/Jasper Studio built in functions such as DAYS / DAYSINMONTH etc. 

Exception in thread "main" net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: DAYS(DATE(1987,02,01),new Date())
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:291)
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:618)
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:586)
    at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1020)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:568)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:552)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:281)
    at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:163)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:281)
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:504)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2026)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeader(JRVerticalFiller.java:613)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeaders(JRVerticalFiller.java:535)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:161)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:558)
    at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:396)
    at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:91)
    at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:456)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:863)
    at jasperSpfinalTest.FinalTestIterator.main(FinalTestIterator.java:84)
Caused by: java.lang.NoClassDefFoundError: net.sf.jasperreports.functions.standard.DateTimeFunctions

 

Link to comment
Share on other sites

  • Solution

I got it to be working after adding dependency jars to the build path. 

You need jasperreports functions and joda time jars for it to be working. both the jars can be found below.

https://sourceforge.net/projects/jasperreports/files/jasperreports/JasperReports%206.2.0/jasperreports-functions-6.2.0.jar/download

https://github.com/JodaOrg/joda-time/releases/download/v2.9.9/joda-time-2.9.9.jar

Link to comment
Share on other sites

OK, i can't check directly on production server... But i've tried a test. I have made a small simple report with some of DateTime functions which are inside jasperreports-functions libs... And it's pretty weird... NOW(), DAY(), SECOND(), DATEVALUE() are OK and functionnal, but DAYS(), YEARS(), MONTHS() give me the error mentionned here...

And these methods are using another method from joda-time lib, so it seems joda-time is the missing libray on theserver

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...