Re: How do I filter on mysql date?

From: Frank (farocc..otmail.com)
Date: Fri Mar 16 2007 - 11:47:52 EDT

  • Next message: Andrus Adamchik: "Re: Running a query over multiple Databases?"

    I changed the statement to:

    SelectQuery select = new SelectQuery(HRApplications.class,
    ExpressionFactory.betweenExp("appDate", c.getTime(), new
    GregorianCalendar().getTime()));

    This seems to have resolved it.

    Thanks for all your help.

    Frank

    ----- Original Message -----
    From: "Peter Schröder" <Peter.Schroede..reenet-ag.de>
    To: <use..ayenne.apache.org>
    Sent: Friday, March 16, 2007 11:34 AM
    Subject: AW: How do I filter on mysql date?

    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:farocc..otmail.com]
    Gesendet: Freitag, 16. März 2007 15:32
    An: use..ayenne.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.Schroede..reenet-ag.de>
    To: <use..ayenne.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:farocc..otmail.com]
    Gesendet: Freitag, 16. März 2007 14:46
    An: use..ayenne.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



    This archive was generated by hypermail 2.0.0 : Fri Mar 16 2007 - 11:48:24 EDT