Search code examples
sqlhibernatehql

Hibernate query date compare on year and month only


I need to grab some records from a table which has a Column birthDate which is a Date(without time). I need to filter records by comparing against year and month only. For example I want all the users born on March of 1990. The day doesn't matter.

How do you handle it?


Solution

  • You can use from Entity where to_char(birthDate,'YYYY/MM') = '1990/03' this will work for HQL