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

Jasperserver date paramater format


CoffeeKid

Recommended Posts

Hi, New to JasperServer and jasper reports. I've created a simple report that takes two parmaters. A user_id (using a single select input control on jasperserver) and a date field (using a date input control on jasper server).

 

The problem i'm having is when i run the report in iReport. The Date seems to format out for SQL correctly, but when i run it from jasper server, it comes out incorrectly formatted for MySQL.

 

Here's what the date looks like when I do it from iReports:

 

2007-06-27

 

And from JapserServer:

 

Sun Jun 24 12:00:00 MDT 2007

 

Whats the best way to modify the input control on jasper server so that it is in the YYYY-MM-DD format?

 

Thanks,

CoffeeKid

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Yes, I would like to know where to find the documentation (From JasperServer), where it may help to do this... Where is the documation with updated, comprehensive, and detail explanation on how to go about customizing JasperServer (it's web pages, it's JSP, customized input controls... - and please don't mention the User Guide as a detailed doc...:blink:)

 

 

Perhaps if all you need is a simple report server, you may want to take a look to OpenReports (http://oreports.com), perhaps they might be sensitive about the connection type you are establishing...

 

Regarding your input field - if you can't (or don't know, as it is in this case) how to do it in Jasper Server, then tackle the problem from Jasper Reports (basically alter your jrxml to deal with the problem)

 

Under your Parameter Field Definition (in your JRXML), provide it with a default parameter expression value - perhaps your parameter could be turn into a string and then let MSSQL Server deal with it as a Date by turning it into a formatted date:

 

( $P{MY_DATE}.toString().substring(3,4).equals(" ") == true )

? (new SimpleDateFormat("yyyy-MM-dd")).format(( new SimpleDateFormat("EEE MMM dd hh:mm:ss 'MDT' yyyy")).parse($P{MY_DATE}.toString()))

: $P{MY_DATE}

 

You can test the expression under beanshell (a quick way to test Java Expressions - maybe someone has a quicker method - I would like to know)

 

You may also try to store the date on your table (yet probably not something you may be able to do at this point) as a long and then have all dates converted to long - in either case you can, most of the times, resolve this problems using your jrxml, or perhaps your a scriptlet in the jrxml (external java helper with pre and post report hooks)

 

I hope this helps... Now where is that, so desired, doc for Jasper Server?

 

Also, this Jasperforge.org site... Why does my login have to timeout so soon??? (I can't even post a message wihtout first saving it to my buffer... talk about usability).

Link to comment
Share on other sites

The JasperServer and JasperAnalysis Ultimate Guides have more detailed documentation. See http://jasperforge.org/sf/wiki/do/viewPage/projects.jasperintelligence/wiki/HomePage

 

 

A date parameter running in JasperServer appears as a java.util.Date when it is a parameter in the JasperReport. The conversion that shija03 outlines is correct.

 

Sherman

JasperSoft

 

 

PS. The timeouts on JasperForge are about 20 mins. Your network settings and environment can make that shorter.

Link to comment
Share on other sites

So, the current parameter with a default value in my jrxml file looks like this:

Code:

<parameter name="the_date" isForPrompting="true" class="java.util.Date">
<defaultValueExpression >
<![CDATA['2007-01-01']]>
</defaultValueExpression>
</parameter>

How would i modify that to do what you recommend?

 

Thanks,

CoffeeKid

Post edited by: CoffeeKid, at: 2007/06/28 22:33

Link to comment
Share on other sites

<![CDATA[

( $P{the_date}.toString().substring(3,4).equals(" ") == true )

? (new SimpleDateFormat("yyyy-MM-dd")).format(( new SimpleDateFormat("EEE MMM dd hh:mms 'MDT' yyyy")).parse($P{the_date}.toString()))

: $P{the_date}

]]>

 

BTW - you should use a GUI editor for jrxml - it really has its advantages. Try iReports (I prefer it over the JasperAssistant's Eclipse plugin) it will save you time, and speed up getting things done rather than staring at JRXML files with your favorite editor - iReports is like Crystal Reports GUI for designing reports... but better

Link to comment
Share on other sites

  • 2 weeks later...

hi,

 

i have the same problem, and i followed the shija03 changed the code, but it gave me error message: Incompatible conditional operand types String and Date.

any idea what i sould do now? i've been working on this for couple days alread....

 

thanks.

Post edited by: kelly, at: 2007/07/13 22:16

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