EricWiz Posted August 1, 2006 Share Posted August 1, 2006 Hey all, I am evaluating iReports right now and this platform is foreign to me. I am familiar with Crystal Reports and M$ Report Services for 2000. I have what I assume is a basic question. How do I utilize a parameter in an SQL statement? For example,if I have a statement like:Select * from ordersand I want to constrain by date:select * from orders where dt >= (date) and dt <= (date)How do I do it? I have looked around and it does not seem to me to be clear. I would like to allow my customers to customize their reports based on parameters. If someone could provide a simple example it would be greatly appreciated! Thanks,Eric Link to comment Share on other sites More sharing options...
edxerx Posted August 1, 2006 Share Posted August 1, 2006 im new to ireport too, just been digging it for 2 weeks :laugh: anyway on the parameter thing in ireport MENU->VIEW->PARAMETER add one parameter here's an example on what u should fill ----------------------------------Parameter Name : ReportDateParameter Class Type : java.lang.dateDefault Value Expression : "" (this is a default value if it's not given during run time)Is for prompting : YES---------------------------------- Then in your sql just use something like this SELECT * FROM table WHERE field=$P{ReportDate}; hope this helps :) Link to comment Share on other sites More sharing options...
EricWiz Posted August 1, 2006 Author Share Posted August 1, 2006 Yup! That works :)Thanks edxerx.. I also noticed that you can then use a parameter with the same name in the JasperReports server and you get the prompt on the page when you call up the report. Ok... So far so good.... My next two things to tackle I think will be expressions and charts. Whoohoo! E Link to comment Share on other sites More sharing options...
pjain Posted December 4, 2008 Share Posted December 4, 2008 Hello All,I am very new to Jaspersoft as well.Is there a way to set a default value expression for Parameter Class Type: java.lang.date.I tried "Jan 1, 2008" and "2008-01-01" but both values erred out as "can not cast string to date".Please help!Thanks Link to comment Share on other sites More sharing options...
CaptnTony Posted December 4, 2008 Share Posted December 4, 2008 will have to do something like new java.lang.date(....) as the default value expression I think. Link to comment Share on other sites More sharing options...
pjain Posted December 4, 2008 Share Posted December 4, 2008 Thank you CaptnTony!Your suggestion worked!I set the default date for Jan 1, 2008 and it worked.new java.util.Date(20080101) Thank you again! Puneet Link to comment Share on other sites More sharing options...
pjain Posted December 4, 2008 Share Posted December 4, 2008 correction!The format for default date value expression worked asnew java.util.Date(new GregorianCalendar(2008, 0, 1)).getTime().getTime()) Thankspjain Link to comment Share on other sites More sharing options...
mdahlman Posted December 4, 2008 Share Posted December 4, 2008 pjain's expression looks OK (and he tested it, so it must be valid). But you may find these formats easier to use:new java.util.Date() // defaults to the current datenew SimpleDateFormat("yyyy-MM-dd").parse("2008-01-01") // See SimpleDateFormat docs for lots of other possibilities Regards,Matt Link to comment Share on other sites More sharing options...
javaiiispl Posted April 29, 2011 Share Posted April 29, 2011 can anyone help me how to pass date value from java to ireport(jasper)..... Link to comment Share on other sites More sharing options...
kolaitis Posted April 29, 2011 Share Posted April 29, 2011 In your calling form.. Map reportParameters = new HashMap();reportParameters.put("DATE", super.getDate("selected_Date")); In iReport, assign parameter : DATE , class Type : java.util.Date In iReport Query : Where yourDataBaseFile.DateField = $P{DATE} Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now