Hi Raoul,

Did u try to use java.sql.Date instead of java.util.Date??
I think this might solve your problem!!

Cheers,
Daniel

Raoul Markus wrote:

Hi,

I tried the following code, but this query didn't return any hits:

public static Collection getSessionsOfDay(DBConnector pDbconnector,Date pDateHeld, String pUser) {
...
tCrit.addEqualTo("DATE_HELD", pDateHeld);
...
Query tQuery = new QueryByCriteria(SDBSession.class, tCrit);
}






and I had to replace it by the following (which works, but is no good):


public static Collection getSessionsOfDay(DBConnector pDbconnector,Date pDateHeld, String pUser) {
...
// TODO: this date operations are not nice...
Calendar tCal = Calendar.getInstance();
tCal.setTime(pDateHeld);
// make a string like "2003-8-29", which is recognized by mysql
String tDateStr = "" + tCal.get(Calendar.YEAR) + "-" + (1+tCal.get(Calendar.MONTH)) + "-" + tCal.get(Calendar.DAY_OF_MONTH); tCrit.addEqualTo("DATE_HELD", tDateStr);
...
Query tQuery = new QueryByCriteria(SDBSession.class, tCrit);



in mysql (3.23.55-log), the column is defined as DATE and holds to my opinion only the day (not the time). the java.util.Date of course has the exact time, maybe this causes the null result?


But with the tDateStr I am no longer independend of the db (i.e. which date strings it recognizes).

any tips, thoughts?

Thanks in advance.






--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to