java - Generate report with specific date -
i'm generate report using ireport 4.7.0
i want generate report searching between 2 day,example : when when.
and code:
java.util.date utilstartdate = date1.getdate(); java.sql.date start = new java.sql.date(utilstartdate.gettime()); java.util.date utilstartdate2 = date2.getdate(); java.sql.date end = new java.sql.date(utilstartdate2.gettime()); try { jasperdesign jd = jrxmlloader.load("c:\\users\\admin\\desktop\\sales report.jrxml"); string sql = "select * order1 order_date between "+start+" , "+end+""; jrdesignquery newquery = new jrdesignquery(); newquery.settext(sql); jd.setquery(newquery); jasperreport jr = jaspercompilemanager.compilereport(jd); jasperprint jp = jasperfillmanager.fillreport(jr,null,conn); jasperviewer.viewreport(jp,false); } catch(exception e) { joptionpane.showmessagedialog(null,e.getmessage());
i have error document have no pages.
this first time doing because generate report without specific something.
any help?
i think need apostrophees around dates. otherwise dbms might think arithmetic operation instead of date.
in other words have this:
"select * order1 order_date between 2005-06-25 , 2008-04-13"
and 2005 - 06 - 25 = 1974 , 2008 - 04 - 13 = 1991 results in:
"select * order1 order_date between 1974 , 1991"
instead want this:
"select * order1 order_date between '2005-06-25' , '2008-04-13'"
Comments
Post a Comment