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_CREAT
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, but the precission is a bit tricky if you record the datetime(not only date).
4>(((CDB_CREATE_DATE_TIME - CCANCELLATION_DATE)/24/60/60/10)-1)>3
/24/60/60/10 is hours in 1 day, minute in 1 hour, second in 1 minute and 10 is the precission i think (1/10s), cz i get 69.44444444444445 for 6 days different if i dont devide with 10 and put -1 at the end