How can I use Datediff() in HQL
I'm trying to get the difference between dates. In my SQL SERVER it's works fine: Select CSERVICE_ORDER_ID FROM TSERVICE_ORDERS WHERE DATEDIFF(DAY, CDB_CREATE_DATE_TIME, CCANCELLATION_DATE) = 4 But in my HQL query I'm not getting it. The function Datefiff works in HQL Query? Is there any function with the same behavior? HQL doesn't support datediff, but if you still want to use datediff, you should use createNativeQuery() or createSQLQuery() to write that in sql. In your example, you just need the id anyway, not entity object, so this should be enough. or you can use in hql something like this