Reputation: 67
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
Upvotes: 3
Views: 1439
Reputation: 1270993
This query:
SELECT COUNT(a)
FROM Appointment a
WHERE DATE(a.startDate) = ?1
only makes sense of there is a column called a
in Appointment
. That is unlikely. You probably intend:
SELECT COUNT(*)
FROM Appointment a
WHERE DATE(a.startDate) = ?1
Upvotes: 1