Trying to get difference of two Date using DateDiff function giving error

hi im trying to get difference of start_time and end_time(for charts) follwing sample$Library for charts but after changing query im getting below error

JpqlSyntaxException: Errors found for input jpql:[select DISTINCT appointment.doctor.firstName, DATEDIFF(DAY,appointment.appointmentdate,appointment.checkInTime)   from hrems$Appointment appointment group by appointment.doctor.firstName]
CommonErrorNode [<mismatched token: [@12,54:54='(',<27>,1:54], resync=(DAY,appointment.appointmentdate,appointment.checkInTime)   from hrems$Appointment appointment>]

Hi,

JPQL doesn’t support DATEDIFF function.
You can try to use FUNCTION with the native SQL function. FUNCTION | EclipseLink 2.4.x Java Persistence API (JPA) Extensions Reference

1 Like