Keep in mind that Databases are very fussy about Date conversions and any
operations using relational operators between dates
Oracle formats dates with TO_CHAR(date, 'yyyy/mm/dd')
Here is the doc
http://www-db.stanford.edu/~ullman/fcdb/oracle/or-time.html#date%20format
SQLServer uses a bit more obtuse convert format
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
e.g.
FormattedDate =convert(varchar(10),InputDateInDateFormat,1)
formats your date to string 10 char length without century
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp
HTH,
Martin-
----- Original Message -----
From: "Ralf Joachim" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, August 22, 2005 7:53 AM
Subject: Re: [castor-user] [JDO] Using OQL with Date
Hi Sergio,
you should be able to execute such a query with:
OQLQuery query = db.getOQLQuery(
"select a from MyClass a where a.mydate > $1");
query.bind(expirationDate);
QueryResults results = query.execute();
Regards
Ralf
Sergio Collantes schrieb:
Hi all:
I've been having trouble when trying to
build an OQL query using java.util.Date types.
Suppose we have a simple class "MyClass" with
a java.util.Date filed named "myDate".
The query goes like this:
select a from MyClass a where a.mydate > expirationDate
Let's suppose that the object expirationDate is declared
in this way:
Calendar calendar = Calendar.getInstance();
calendar.set (...) // Whe set the expiration date
java.util.Date expirationDate = calendar.getTime();
The field myDate is a varchar in the database, and the
mapping is correct (i.e. the data is converted to Date
correctly in the JDO, i have tried it and it works).
The mapping is declared as follows:
<field name="mydate" type="date">
<sql name="mydate" type="char[dd/MM/yyyy]"/>
</field>
I assume in doing the wrong query, ¿can anybody tell
me what do I have to do?
-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message
to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------