Search code examples
javagoogle-app-enginejpadatastore

How to get an entity between two dates in appengine datastore for


I have an appointment table with appointment date as one of the columns. I want to retrieve all the appointments between two dates in appengine datastore using JPA. can please let me know how to achieve this? I tried with following query but it did not work.

select a from Appointment a where (apptSts='p' or apptSts='a') and (apptDate>=:fromDate or apptDate<=:toDate)


Solution

  • To retrieve appointments between 2 dates, you need to change your query logic to include "and" instead of "or" :

    select a from Appointment
    where apptDate>=fromDate and apptDate<=toDate
    

    You CAN have inequality filers on the same property in appengine, but they can't be combined with OR.

    See examples in gql reference, which should also apply to JPA.