Is there any syntax error in this code or query because i am not getting the required report? I have created a JFrame with JDatechoosr. When i select the dates and click view report, it gives me empty report while i know there is data within the specified date range. Kindly help me.

try{
            JasperDesign jd = JRXmlLoader.load("Purchase.jrxml");
            String sql = "select * from purchase where purchase_date between "
                    + "'"+DateChooser_frm.getDate().toString()+"' and '"+DateChooser_to.getDate().toString()+"'";
            JRDesignQuery query = new JRDesignQuery();

            query.setText(sql);
            jd.setQuery(query);
            JasperReport jr = JasperCompileManager.compileReport(jd);
            JasperPrint jp = JasperFillManager.fillReport(jr, null,con);
            JasperViewer.viewReport(jp,false);

        }

        catch(JRException ex){
            JOptionPane.showMessageDialog(null, ex);
        }
        catch(Exception ex){
            JOptionPane.showMessageDialog(null, ex);
        }

Is the date format correct? (yyyy-mm-dd)

yeah, i used SimpleDateFormatfor that, and i am using dates in other sections of the app but here in this report, i am having the issue, but i am not getting any exception or error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.