Jump to content
We've recently updated our Privacy Statement, available here ×

passing a date parameter into a sub report not working - any ideas?


john.v.little

Recommended Posts

I have a subreport which I want to re-use 5 times on the main report, just passing in different date ranges (today, yesterday, lst month etc).

The sub report takes 2 java.util.date parameters.  If I run the sub report on its own, either using the prompt for option and chosing dates, or entering TODAY( ) in the "Default Vlue Expression", the sub report shows the correct values.

Now if I call the sub reports from the main report, passing to them the same expression (e.g. TODAY( )), I get all zeros back in all the sub reports.

In the Mail report I have this:

<detail>
<band height="340" splitType="Stretch">
<subreport runToBottom="true">
<reportElement x="80" y="0" width="80" height="200" uuid="7cd92266-e1d4-4394-a58a-67430889f229"/>
<subreportParameter name="P_FROM">
<subreportParameterExpression><![CDATA[TODAY( )]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_TO">
<subreportParameterExpression><![CDATA[TODAY( )]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["dashboard/dash-slice.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="160" y="0" width="80" height="200" uuid="de0997be-7f4d-4ee7-8b70-8636fe152b05"/>
<subreportParameter name="P_FROM">
<subreportParameterExpression><![CDATA[EDATE(NOW( ),-1)]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="P_TO">
<subreportParameterExpression><![CDATA[new Date()]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["dashboard/dash-slice.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
 
This should pass the parametes into the sub report. but I notice there is no way to define the type of the parameters going in - are they converted to strings or simlar?   Is this the problem perhaps?
 
In the sub report, the parameters are defined like this:
 
<parameter name="P_FROM" class="java.util.Date">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA[TODAY( )]]></defaultValueExpression>
</parameter>
<parameter name="P_TO" class="java.util.Date">
<parameterDescription><![CDATA[]]></parameterDescription>
<defaultValueExpression><![CDATA[TODAY( )]]></defaultValueExpression>
</parameter>
 
In the SQL, I have something like this:
 
<queryString language="SQL">
<![CDATA[select * from
(select count(p.id) as registrations
from players p
where date(p.creationTime) BETWEEN $P{P_FROM} AND $P{P_TO}

 

Link to comment
Share on other sites

  • Replies 1
  • 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...