cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Schröder <Peter.Schroe...@freenet-ag.de>
Subject AW: How do I filter on mysql date?
Date Fri, 16 Mar 2007 15:34:19 GMT
sorry, bad copy and paste:

  Calendar c = new GregorianCalendar();
     c.add(Calendar.DATE, -60);
     SelectQuery select = new SelectQuery(HRApplications.class, ExpressionFactory.betweenExp("appDate",
c, new GregorianCalendar()));
     List records = context.performQuery(select);
     return records;



-----Ursprüngliche Nachricht-----
Von: Frank [mailto:farocco@hotmail.com] 
Gesendet: Freitag, 16. März 2007 15:32
An: user@cayenne.apache.org
Betreff: Re: How do I filter on mysql date?

I am getting "between cannot be resolved"

Thanks

Frank
----- Original Message ----- 
From: "Peter Schröder" <Peter.Schroeder@freenet-ag.de>
To: <user@cayenne.apache.org>
Sent: Friday, March 16, 2007 10:14 AM
Subject: AW: How do I filter on mysql date?


hi frank,

what is the result you get?

i would try it that way:

     Calendar c = new GregorianCalendar();
     c.add(Calendar.DATE, -60);
     SelectQuery select = new SelectQuery(HRApplications.class, 
ExpressionFactory.between);
     List records = context.performQuery(select, 
ExpressionFactory.betweenExp("appDate", c, new GregorianCalendar()));
     return records;



-----Ursprüngliche Nachricht-----
Von: Frank [mailto:farocco@hotmail.com]
Gesendet: Freitag, 16. März 2007 14:46
An: user@cayenne.apache.org
Betreff: 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


Mime
View raw message