Jump to content
Changes to the Jaspersoft community edition download ×

How to compare timestamp and a date (or timestamp and a timestamp)?


patricia.williams

Recommended Posts

I have a variable that I've defined as a date.  I have a timestamp that is read from my database.

<field name="eff_stop_ts" class="java.sql.Timestamp"/>

<variable name="lateday" class="java.sql.Date">
<variableExpression><![CDATA[new java.util.Date()]]></variableExpression>
 
I want to see if the timestamp > date
 
$F{eff_stop_ts}.after($V{lateday}) ? "" :  $F{holdoffice}
 
which gets these errors:
 
returning this 
net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $F{eff_stop_ts}.after($V{lateday}) ? "" :  $F{holdoffice}
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:506)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:481)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:362)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $F{eff_stop_ts}.after($V{lateday}) ? "" :  $F{holdoffice}
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:264)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:610)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:578)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1015)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:572)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:556)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:454)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2029)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:755)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:262)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:122)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:551)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:119)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date
at CandidateTreasurers_1485893188234_921646.evaluate(CandidateTreasurers_1485893188234_921646:250)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:251)
... 14 more
 
I also tried setting latedate to a timestamp and just doing eff_stop_ts > latedate and it returns errors as well.
 
 
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...