How to query for a portion of a date?

From: McBrayer, Roy (Roy.McBraye..ail.va.gov)
Date: Mon Jul 19 2004 - 14:52:40 EDT

  • Next message: Tore Halset: "Re: How to query for a portion of a date?"

    I would like to construct a query on a database that returns date objects
    and I would like to use restrict the dates returned to a particular year.
    How do I restrict the resultset to only those dates?

    I am trying the code below. The only query that is being done is is the
    original "e" expression for the siteNumber. Nothing is being "anded" to the
    query. What am I doing wrong?

        SiteDailySum sdm = new SiteDailySum();

        ctxt.registerNewObject(sdm);

        Date testDate1 = new Date(2004,1,1,0,0,0);

        Date testDate2 =new Date(2005,1,1,0,0,0);

        Expression qual = ExpressionFactory.greaterExp("summaryDate",
    testDate1);
        Expression qual2 = ExpressionFactory.lessExp("summaryDate", testDate2);
            Expression e = ExpressionFactory.matchExp("siteNumber",station);
        e.andExp(qual);
        e.andExp(qual2);
            System.out.println("Query is " +e.toString());
       SelectQuery query = new SelectQuery(SiteDailySum.class, e);

        records = ctxt.performQuery(query);



    This archive was generated by hypermail 2.0.0 : Mon Jul 19 2004 - 14:52:49 EDT