I am currently writing a Java Swing application that reads data from a MYOB database file and displays specific information in a table. I was able to successfully generate the required SQL queries, but I had problems with the ability to search between dates (our database is quite large, so we are trying to limit the results). An example of one of my queries below (written in Java):
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"
+ ";");
I have two dates (they are actually strings in Java, but formatted as dd / MM / yyyy).
I tried using a different sentence ANDin mine WHEREwith the operator BETWEEN, but I get the following error from JDBC[MYOB ODBC]Error getting the literal value of right operand.
The actual instruction is given below:
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"
+ ";");
- ? .
EDIT: sdate edate 25/10/2013, . , , , . , .