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

Problem with date format (yyyymmdd) and parameter


agavus

Recommended Posts

Hi ,

I've been working with IReport for two weeks now and I am having trouble creating a parameter input for my second report.

The dates are not stored in the database as datesformat but as YYYYMMDD and the field class for this field is Big.Decimal. I am trying to find a way the create a parameter with class java.util.date  were the user can enter a start end end date.

Is there an expression to convert the dates that are entered in the parameter to the YYYYMMDD values that are recognized by the SQL.

I used the text field expression

"new SimpleDateFormat("yyyyMMdd").parse($F{DATE_FIELD}.toString())"

to display the YYYYMMDD value from the database as an actual date in the report. What I am looking for is the other way around.

Or is there maybe a simpeler solution.

Thanks for the help.

 

 



Post Edited by Ronald Migo at 01/08/09 12:04



Post Edited by Ronald Migo at 01/08/09 12:04



Post Edited by Ronald Migo at 01/09/09 08:59
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

hi,
 

$P{parameter1} = java.util.date;
USE_AS_A_PROMPT=yes
 

$P{parameter2} = java.lang.Integer;
DEFAULT_VALUE_EXPRESSION=new Integer(new SimpleDateFormat("yyyyMMdd").format($P{parameter1}))
USE_AS_A_PROMPT=no



in your SQL-Statment, you can use $P{parameter2}, maybe $P!{parameter2}



Post Edited by hingerl at 01/08/09 12:36
Link to comment
Share on other sites

Superrrrrrrr.

This work great

Thanks a million.

Just one more question. For another report I want to display the records from the last two weeks. Is it possible to use something like  new date()-14 as a default expression?

Thanks

 



Post Edited by Ronald Migo at 01/08/09 15:59
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...