java oracle 日期时间模糊查询的方法

思路是先将oracle中时间字段转化成字段串,然后与字符串模糊查询
如下:
String strSQLSearch = "SELECT * FROM " + objConfigDB.getTableName() + " WHERE(to_char(creationdatetime,'yyyy-MM-dd hh24:mi:ss') LIKE '%" +strSearch + "%')";

select * from atm1_operatelog t where to_char(t.operatetime,'yyyy-MM-dd') like '2006-10-16'

同时反过来也是一样可行的
select * from atm1_operatelog t where t.operatetime like to_date('2006-10-16','yyyy-MM-dd')
将字段串转化为时间然后使用like关键字

posted @ 2008-02-29 10:08  wj-conquer  阅读(2282)  评论(0编辑  收藏  举报