dkim18
asked on
EJB QL - selecting current year in date type
Hi Experts,
I am working on jboss seam web app and I need to modifiy ejb ql so that I can use same code next year without modifying code.
select qualReport from QualReport qualReport where qualReport.countyName='che rokee' order by qualReport.quarter, qualReport.rowOrder
The above works fine, but I want to select rows only for current year. There is a createdDate column that stores oracle Date when rows were inserted and there are some rows that were created this year.
thanks,
I am working on jboss seam web app and I need to modifiy ejb ql so that I can use same code next year without modifying code.
select qualReport from QualReport qualReport where qualReport.countyName='che
The above works fine, but I want to select rows only for current year. There is a createdDate column that stores oracle Date when rows were inserted and there are some rows that were created this year.
thanks,
you can user Year(GetDate()) in the query then you will get the year of the date
example
"SELECT billingDetails FROM CreditCard as billingDetails where billingDetails.created > Year(GetDate())"
"SELECT billingDetails FROM CreditCard as billingDetails where billingDetails.created > Year(GetDate())"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-
Calendar calObj = new GregorianCalendar(new GregorianCalendar().get(Ca
logger.debug("The calender corresponding to first of the year is: " + format.format(calObj.getTi
criteria = em
.createQuery("SELECT billingDetails FROM CreditCard as billingDetails where billingDetails.created > '" + format.format(calObj.getTi