I have a java.util.Date
field in an @Entity
and would like to get the distinct months from that column.
Suppose I only had three rows, with 14/07/2010, 24/11/1975 and 03/11/1975 (European date format - day/month/year), I would like to get the following back from Hibernate to go into a dropdown for filtering the data:
07/2010
11/1975
(or corresponding Date objects with the other fields set to zero - to be honest precisely how the data comes back isn't too important as I can work around that).
I'm guessing a database-agnostic approach in HQL isn't possible - any suggestions?
What about :
select distinct month(c.birthday), year(d.birthday) from Cat c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With