Dates.......

Hi All thanks in advance for any help.

I'm trying to construct a report which amongst other things uses a 'from' and 'to' date as part of the select.

To do this I have created 2 parameters called 'date_from' & 'date_to' which are of class java.sql.Date and this give the end user a nice little calander icon to select the dates.

I also have created 2 parameters called 'from_date' & 'to_date' which are are of class java.lang.String.  The default vale expression is set to 'new SimpleDateFormat("dd/mm/yyyy").format($P{date_to}) (or date_from) These parameters are then embeded in the SQL as below

... and it.dstamp between to_date ($P{from_date}, 'dd/mm/yyyy') and to_date($P{to_date}, 'dd/mm/yyyy') ...

In studio this works sometimes, and sometimes not....   

When I display all the parameters to the report header, sometimes the string parameters show a date, and most of the time null.

On the reports server, it never works.

I have amended the jasper_config.properties file on the server to suit, I have added a suitable patten in the text field of the parameter, and I have repeatedly banged my head on my desk.

 

Any assistance would be gretly appreciated.

 

Many Thanks  

 

tafty's picture
2
Joined: Apr 15 2015 - 2:40am
Last seen: 1 year 1 month ago

3 Answers:

1. I am don/t understand which reason make string parameters? You can use dates in query.
2. Order parameters sometimes is important. Place parameters in tree in order when dependent parameters after parent: date_from, date_to, from_date, to_date

Good luck

sanbez's picture
6400
Joined: Jan 11 2011 - 2:06am
Last seen: 2 years 8 months ago

You'll need to align Java Date with SQL Date format.

hozawa's picture
177867
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 12 months ago

Many thanks for your assistance, got it working now.

tafty's picture
2
Joined: Apr 15 2015 - 2:40am
Last seen: 1 year 1 month ago
Feedback