Hibernate query date compare on year and month only

半城伤御伤魂 提交于 2019-12-19 03:42:11

问题


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?


回答1:


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




回答2:


you may try this

 select * from table where month(birthdate)=03 and year(birthdate)=1990


来源:https://stackoverflow.com/questions/12973700/hibernate-query-date-compare-on-year-and-month-only

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!