Query by datetime in JDOQL / Java / GAE

Posted by Jan Kuboschek on Stack Overflow See other posts from Stack Overflow or by Jan Kuboschek
Published on 2010-03-19T04:57:03Z Indexed on 2010/03/19 5:01 UTC
Read the original article Hit count: 389

Filed under:
|
|
|

I'm working on a GAE app. I want to query datastore and retrieve all records between startDate and endDate. Each record has a datetime field. I'm using a query similar to this (the below code is something I quickly grabbed - I'm not near my developer machine.):


Query query = pm.newQuery(Employee.class);
query.setFilter("lastName == lastNameParam");
query.setOrdering("hireDate desc");
query.declareParameters("String lastNameParam");

try {
    List results = (List) query.execute("Smith");
    if (results.iterator().hasNext()) {
        for (Employee e : results) {
            // ...
        }
    } else {
        // ... no results ...
    }
} finally {
    query.closeAll();
}

How do I have to format the date to form a correctly working query? How is the datetime stamp stored in datastore? As timestamp? Fully formatted? I can't find ANY information on this. Please help.

© Stack Overflow or respective owner

Related posts about jdoql

Related posts about gae