title: Searching between dates in SQL with JDBC?
body: <p>I'm currently writing a Java Swing application that reads data in from a MYOB database file and displays certain information in a table. I've been able to successfully generate the required SQL statements but I'm having trouble adding the ability to search between dates (our database is pretty large so we are trying to limit results). An example of one of my queries is below (written in Java):</p>
  
  <pre><code>rs = stmt.executeQuery("SELECT sales.InvoiceNumber, sales.ShipToAddress, sales.Date "
                          + "FROM sales, customers "
                          + "WHERE sales.CardRecordID = customers.CardRecordID "
                          + "AND customers.Name = 'Cash Sales' "
                          + "ORDER BY sales.ShipToAddress ASC, sales.Date DESC"
                          + ";");
  </code></pre>
  
  <p>I have two dates (they are actually Strings in Java but are formatted as dd/MM/yyyy).</p>
  
  <p>I have tried using another <code>AND</code> clause in my <code>WHERE</code> with a <code>BETWEEN</code> statement but I get the following error from JDBC <code>[MYOB ODBC]Error getting the literal value of right operand.</code></p>
  
  <p>Actual statement is below:</p>
  
  <pre><code>rs = stmt.executeQuery("SELECT sales.InvoiceNumber, sales.ShipToAddress, sales.Date "
                          + "FROM sales, customers "
                          + "WHERE sales.CardRecordID = customers.CardRecordID "
                          + "AND customers.Name = 'Cash Sales' "
                          + "AND sales.Date BETWEEN " + sdate + " AND " + edate + " "
                          + "ORDER BY sales.ShipToAddress ASC, sales.Date DESC"
                          + ";");
  </code></pre>
  
  <p>Is anyone able to help me work out correct syntax for this? It's the last piece of functionality missing.</p>
  
  <p>EDIT: Current value of <code>sdate</code> and <code>edate</code> respectively are both 25/10/2013 as they default to today's date. I have set up the dummy file I am testing to ensure it will provide data with this date range. Also for clarficiation I would like the search dates to be INCLUSIVE.</p>