Stanley Mungai
Stanley Mungai

Reputation: 4150

Print a field when certain value is not present Jasper reports

I am creating a JasperReports's report using iReport. I have a date field where once instance is 01-JAN-1900. I need any time the date field has this value then null value is printed. I have tried this:

<textField pattern="dd-MMM-yyyy" isBlankWhenNull="true">
                    <reportElement uuid="4dd05795-8363-4cf3-ad30-239aac3a086f" x="3" y="0" width="63" height="15">
                        <printWhenExpression><![CDATA[$F{TRAN_DATE} != "01-JAN-1900"]]></printWhenExpression>
                    </reportElement>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{TRAN_DATE}]]></textFieldExpression>
                </textField>

But the value is still getting printed. How do I achieve this?

Upvotes: 0

Views: 1340

Answers (2)

Viki888
Viki888

Reputation: 2774

If your field $F{TRAN_DATE} is in java.util.Date type, change it to java.lang.String and your condition should work.

Upvotes: 0

Robert Mugattarov
Robert Mugattarov

Reputation: 1298

You cannot compare dissimilar types. Drop the String literal and compare datetime types.

Upvotes: 1

Related Questions