Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate query date compare on year and month only

Tags:

sql

hibernate

hql

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?

like image 668
braincell Avatar asked Oct 19 '12 11:10

braincell


1 Answers

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

like image 196
Jigar Parekh Avatar answered Nov 14 '22 08:11

Jigar Parekh