Hibernate query date compare on year and month onl

2019-02-14 23:31发布

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?

2条回答
看我几分像从前
2楼-- · 2019-02-15 00:11

you may try this

 select * from table where month(birthdate)=03 and year(birthdate)=1990
查看更多
We Are One
3楼-- · 2019-02-15 00:13

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

查看更多
登录 后发表回答