Looking for an HQL Query to parse Calendar Date

abuyusuf35
abuyusuf35 used Ask the Experts™
on
Hi - I need a hibernate HQL query which can parse a calendar date in a database field and extract (a) the calendar year from the date( or timestamp) and also (b) the calendar month from the date( or timestamp). The purpose is to retrieve a set of entries by year or by month

Thanks

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
check this link
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-expressions

these functions are only supported if the underlying database is supporting the same, which is one of the cool things about HQL. If Hibernate doesn't understand a particular syntax, say a call to sysdate() or your adddate function that is in SQL, then it just passes the text to the database. Meaning if the database suports those functions it will work. So it means that your HQL query doesn't have to always have just HQL, but some SQL can work
I found a solution to my question - select * from Holiday c where c.holidayDate between :start and :end

Author

Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for abuyusuf35's comment http:/Q_27293994.html#36516345

for the following reason:

I found a solution elsewhere
this solution is mentioned in the link

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial