public ReportObject runReport(Date start, Date end, int userid) {
                         
        // Declare variable
        int count = 0;
        int rvalue = -1;
        float total = 0;
        
        // Set the report start date to one day before the selected date
        Calendar startCal = Calendar.getInstance();
        startCal.setTime(start);
        startCal.add(Calendar.DATE, -1);
        Date newStart = startCal.getTime();
        
        // Set the report end date to one day after the selected date
        Calendar endCal = Calendar.getInstance();
        endCal.setTime(end);
        endCal.add(Calendar.DATE, 1);
        Date newEnd = endCal.getTime();
        
        // Convert the start and end dates to SQWL based dates
        java.sql.Date startDate = new java.sql.Date(newStart.getTime());
        java.sql.Date endDate = new java.sql.Date(newEnd.getTime());

        // Create a new instance of the report object
        ReportObject report = new ReportObject();
        
        // Declare query statement
        String query = "SELECT * FROM tracare_entries WHERE userid = ? AND datetime BETWEEN ? AND ?";
                
        try {

            // Create the prepared statement and fill in the values
            PreparedStatement pstmt = conn.prepareStatement(query);
            pstmt.setInt(1, userid);
            pstmt.setDate(2, startDate);
            pstmt.setDate(3, endDate);
            
            // Execute the statement
            ResultSet rs = pstmt.executeQuery();
            ResultSetMetaData rsmd = rs.getMetaData();
            while (rs.next()) {

                // Check to see if the weight from the selected entry is less than the lowest weight
                if (rs.getFloat(4) < report.getLowestWeight()) {
                    report.setLowestWeight(rs.getFloat(4));
                    report.setLowestDate(rs.getDate(3));
                }
                
                // Check to see if the weight from the selected entry is greater than the highest weight
                if (rs.getFloat(4) > report.getHighestWeight()) {
                    report.setHighestWeight(rs.getFloat(4));
                    report.setHighestDate(rs.getDate(3));
                }
                
                // Update the average totals
                count++;
                total += rs.getFloat(4);
            }

            // Calculate the average weight
            report.setAverageWeight(total / count);
            
            // Check to see if there were no entries used in the report and set the report values to defaults
            if (count == 0) {
                report.setHighestDate(end);
                report.setLowestDate(start);
                report.setHighestWeight(0);
                report.setLowestWeight(0);
                report.setAverageWeight(0);
            }
   
        } catch (SQLException ex) {
            rvalue = -3;
        }

        // Return the result
        return report; 
    }