Jasper plugin datetime

Hi,

Does anyone know what ‘Parameter Class’ a parameter within IReport must be when I transfer a Servoy (Javascript) datetime value through the parameter ‘parameters’ of runReport.
I’m know getting JasperReport type errors when accessing the datetime parameter.

Or must I pass the datetime as a String ?

Regards,

a datetime will be a java.util.Date

Where can i download this plugin? Thanks…

christineb1979:
Where can i download this plugin? Thanks…

http://code.google.com/p/servoy-jasperr … loads/list

Regards,
Andrei

ptalbot:
a datetime will be a java.util.Date

Hi Patrick,

Thanks, but I need a java.sql.Timestamp because I use the datetime parameter in the report SQL query. A java.util.Date throws an error when the report SQL runs…
Do you know a workaround in Servoy or in I-Report (JasperReport) ?

Regards,

If the parameter has the type java.util.Date and your SQL looks like this:

SELECT * FROM test WHERE from_date >= $P{from_date}

it should work. If not an workaround would be to give the parameter the type string and set the servoy date with:

utils.dateFormat(date,'yyyy-mm-dd');

Regards,
Stef

Hi Stef,

Thanks.

If I make the parameter type java.util.Date then I get following error within I-Report :

Caused by: java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Timestamp at saldi32balans_1283947499421_609992.evaluate(saldi32balans_1283947499421_609992:380) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:182)

I’ll test the string option but I still need a java.util.Date for easy/nice displaying/printing of that date value itself…

Regards,

What JasperReport Version are you using?

Can you post you SQL?

Regards,
Stef

I get the error with a simple sql … where entry_date>=$P(date_range_start) in I-report and when run from Servoy.

Verson 3.7.1

I get the error with a simple sql … where entry_date>=$P(date_range_start) in I-report and when run from Servoy.

Should that not be curly braces : $P{date_range_start} ?

You could always try converting the java.util.Date to java.sql.Timestamp either in the Jasper report or in Servoy before passing the parameter:

var date_range_start_as_timestamp =  new java.sql.Timestamp(date_range_start.getTime())

Hello,

When I pass in dates from Servoy that need to be used in SQL queries from within my jasper reports I do the following to the date…

new SimpleDateFormat("yyyy-MM-dd").format($P{DATE})

This will create a string from your date that will be formatted like ‘2010-09-08’.

If you use that string in your query, the DB will take care of ‘casting’ it for you to a timestamp (at least MySQL will)

Also note that to use a parameter in your SQL query you must make the parameter executable by adding a ‘bang’ after $P

$P!{PARAM}

Hope this helps

@Thomas : Yes, I did use {} (typo in message)
@Thomas : Your var date_range_start_as_timestamp = new java.sql.Timestamp(date_range_start.getTime()) looks very promising ! I’m gonna test it… The java.sql.Timestamp parameters work very good in the sql query and you can use that parameter without de ! (bang). Thanks a lot !

@Jeff : Thanks for the info. I tested this afternoon already with $P**!**{start_date} and when start_date is a String parameter (‘yyyy-MM-dd’) then :D

@Everybody : Thanks and consider problem solved…

Regards,

Hi Lambert,

I’m currently couldn’t get the SQL query working with a date parameter for the jasperreport. It would be very nice if you could explain your parameter properties and Servoy functions if your solution is still running.
In iReport (v. 4.6.0) I tried the parameter settings of $P{DATE_FROM} and $P{DATE_TO} as java.sql.Timestamp, java.util.Date and java.lang.String. I also tried the date formatting hints in this topic, but I always get errors and the report does not generate.

Regards,