If the datatype on your table is defined as a DATE or DATETIME or TIMESTAMP, then you should not be trying to supply a String format to your SQL. You should be using a java.util.Date or java.util.Calendar. You can even provide a Custom Type Handler for this to ensure that the value that you supply to iBatis is a java.util.Calendar and the value returned from iBatis is a java.util.Calendar.
/* (non-Javadoc) * @see com.ibatis.sqlmap.client.extensions.TypeHandlerCallback#getResult(com.ibatis.sqlmap.client.extensions.ResultGetter) */ public Object getResult(ResultGetter getter) throws SQLException { java.util.Calendar cal = java.util.Calendar.getInstance(); java.sql.Timestamp ts = getter.getTimestamp(cal); if (getter.wasNull()) return null; // This is due to some odd behavior when dealing with proxy objects. if(ts == null) { cal = null; } else { cal.setTime(ts); } return cal; } /* (non-Javadoc) * @see com.ibatis.sqlmap.client.extensions.TypeHandlerCallback#setParameter(com.ibatis.sqlmap.client.extensions.ParameterSetter, java.lang.Object) */ public void setParameter(ParameterSetter setter, Object parameter) throws SQLException { if(parameter == null) { setter.setNull(java.sql.Types.DATE); } else { java.util.Calendar cal = (java.util.Calendar)parameter; setter.setTimestamp(new java.sql.Timestamp(cal.getTimeInMillis()), cal); } } However, if your column is defined as a VARCHAR and you need to use a String format for comparison, then I would use a Custom Type Handler to format the supplied Date object into a String for the given format utilizing the java.text.DateFormat. Chris Mathrusse christopher.mathru...@sybase.com mm/dd/yy format issue (urgent) HelpMePlz to: user-java 10/07/2009 04:12 AM Please respond to user-java Hi all, in my ibatis query , ihave to use both mm/dd/yyyy and mm/dd/yy . can you please tell me how can we do that. i have one question right now in my ibatis query i am using mm/dd/yyyy format if i have given date in that format like 02/03/2009 i am getting results , if i changed the date format mm/dd/yy like 02/03/09 by giving this format i am not getting results . if any one knows anws for these question plz reply me it is very urgent for me -- View this message in context: http://www.nabble.com/mm-dd-yy-format-issue-%28urgent%29-tp25783905p25783905.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org