You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Frank <fa...@hotmail.com> on 2007/03/16 14:45:31 UTC

How do I filter on mysql date?

Hello,

I need to show the last 60 days of records from my MySQL database.
This is not working.

    private List filter() {
     Calendar c = new GregorianCalendar();
     c.set(c.get(Calendar.YEAR),(c.get(Calendar.MONTH)-60), 1, 0, 0, 0);
     DataContext context = DataContext.getThreadDataContext();
     Expression qualifier3 = Expression.fromString("appDate > $date");
     qualifier3 = qualifier3.expWithParameters(Collections.singletonMap("date", c.getTime()));
     SelectQuery select3 = new SelectQuery(HRApplications.class, qualifier3);
     List records = context.performQuery(select3);
     return records;
    }

What am I doing wrong?

Thanks
Frank