在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关键字


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3