I am trying to retrieve all the entity from the TransactionE t entity where the month of t.purchasedDate is equal to the current month.
However, I encountered a syntax error when my code run.
String query = "SELECT t FROM TransactionE t WHERE Month(t.purchaseDate) = Month(" + getCurrentDate()+")";
Query q = em.createQuery(query);
Any help please?
getCurrentDate() is a function that will return the date of current day in "yyyy-MM-dd" format.
The below is a query that I was hoping to achieve. SELECT t FROM TransactionE t WHERE Month(t.purchaseDate) = Month("2013-10-06")
Error : Caused by: Exception [EclipseLink-8025] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.JPQLException Exception Description: Syntax error parsing the query [SELECT t FROM TransactionE t WHERE Month(t.purchaseDate) = Month(getCurrentDate()), line 1, column 40: unexpected token [(].