user1298426
user1298426

Reputation: 3717

Is there any way to remove time to compare dates only in jasper?

I have 2 dates. 1st is

<field name="duedate" class="java.util.Date"/>

& second is current date so I am doing something like this

<![CDATA[ $F{duedate} >= (new java.util.Date()) ? "one" : "two"]]>

which doesn't work if dueDate matches new java.util.Date()

also seems there is some problem with date format. I am using PostgreSQL query to get the date. Say query is like this

    <queryString>select dueDate from table1</queryString>

& then I get that field like this

<field name="duedate" class="java.util.Date"/>

but PostgreSQL dueDate o/p is of type java.sql.date

So field that I declared, will that work as util.date?

Upvotes: 3

Views: 2759

Answers (1)

Endrik
Endrik

Reputation: 2258

java.util.Date has it's own comparison methods ( compareTo(), after(), before() ), and they work in Jasper as well. So you might try something like:

$F{duedate}.compareTo(new java.util.Date() == 0 ? "one" : "two" 

Another possible solution i might think of right now is to make the comparison inside the query of your report, like this:

SELECT
duedate as duedate,
CASE WHEN duedate == sysdate THEN "one" 
ELSE "two" END as comparison
FROM ....

Upvotes: 1

Related Questions