seam 中模糊查询日期:SQl_Convert中 不能识别Varchar?

Mrpublic 2009-05-12
CONVERT(varchar(12) , getdate(), 112 ) ?
说不识别varchar?
为什么呢? 这和seam无关吧 ?

我用的数据库为 eclipse自带的hsql


=========================================

我改為char() 就好了,


=========================================

用上面的方法為什麽我的老是報 wrong data type
不管是換成 getdate() 還是我的表中的字段 ??爲什麽呢?

我放棄用這種方法模糊查詢日期 改為了:

(注; 我的bean.getYearAndMonth()是個Integer型 為200905這個六位數格式; Date 是java.sql.Date;)
String temp=bean.getYearAndMonth().toString();
String temp1=temp.substring(0, 4)+"-"+temp.substring(4)+"-01";
String temp2=temp.substring(0, 4)+"-"+temp.substring(4)+"-31";
Date startDate=Date.valueOf(temp1);
Date endDate=Date.valueOf(temp2);


sql 語句;

em.createQuery("select ebi from Entity ebi where  ebi.startDate >=:sdate and ebi.startDate<=:edate")
.setParameter("sdate", startDate)
.setParameter("edate", endDate).getResultList();
Global site tag (gtag.js) - Google Analytics