query = em.createQuery("SELECT COUNT(a) FROM Appointment a WHERE a.datetime >= ?1 and a.datetime < ?2"); query.setParameter(1, date1, TemporalType.DATE); query.setParameter(1, date2, TemporalType.DATE); So JPQL does not have a DATE() function.
I've tried a.startDate >= day1 AND a.startDate < nextday but it is returning the count of every single appointment