You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by pa...@bt.com on 2001/10/02 16:43:07 UTC

Dates in criteria object

I am having problems getting my oracle database to accept the dates passed
into the criteria which I am building up.

If I pass a date in, it seems to output it into oracle in the wrong format.

If I pass in using addDate the day,year,month integers, it outputs the
entire calendar in the oracle query.

I've tried formating a string to go in but the add function doesn't seem to
support it?

Id there some easy way to use dates in the criteria?

Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Dates in criteria object

Posted by Matthew Forder <fo...@ams.neth.seagate.com>.
Paul,

I had exactly the same problem myself...the addDate method definately doesn't
work.
Here's what I ended up using (a real kludge, and no doubt someone has a much
nicer way of doing it!!)

Vector results = new Vector();

// Get parameters from a form
String fdd = data.getParameters().getString("fromDay");
String fmm = data.getParameters().getString("fromMonth");
String fyy = data.getParameters().getString("fromYear");
String tdd = data.getParameters().getString("toDay");
String tmm = data.getParameters().getString("toMonth");
String tyy = data.getParameters().getString("toYear");

// Search between 2 dates...
Criteria.Criterion cf = criteria.getNewCriterion(SomePeer.CREATED_DATE,
fdd+"-"+fmm+"-"+fyy, Criteria.GREATER_EQUAL);
Criteria.Criterion ct = criteria.getNewCriterion(SomePeer.CREATED_DATE,
tdd+"-"+tmm+"-"+tyy, Criteria.LESS_EQUAL);
criteria.add(cf.and(ct));

// Execute the query
results = SomePeer.doSelect(criteria);

Hope this helps!!

Regards,


paul.hunter@bt.com wrote:

> I am having problems getting my oracle database to accept the dates passed
> into the criteria which I am building up.
>
> If I pass a date in, it seems to output it into oracle in the wrong format.
>
> If I pass in using addDate the day,year,month integers, it outputs the
> entire calendar in the oracle query.
>
> I've tried formating a string to go in but the add function doesn't seem to
> support it?
>
> Id there some easy way to use dates in the criteria?
>
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

--
   ____  | Matthew J. Forder         | Data Center Supervisor
  / / () | Seagate Techology         | Tel:+31 20 316 7468
  \ \ \  | Koolhovenlaan 1           | Fax:+31 20 653 5537
 ()_/_/  | 1119 NB Schiphol-Rijk, NL | matthew.forder@seagate.com