Orcale时间比较

String sql = "select toolName,count(*) as count from KmToolclickCnt cnt where 1=1";


if(!ValidateUtils.isEmpty(toolbarclick.getToolName())){
sql += " and cnt.toolName like '%"+toolbarclick.getToolName()+"%'";
}
if(!ValidateUtils.isEmpty(beginDate)){
sql += " and cnt.goTime >=to_date('" + beginDate+"','yyyy-mm-dd hh24:mi:ss')";
}
if(!ValidateUtils.isEmpty(endDate)){
sql += " and cnt.goTime <=to_date('" + endDate + "','yyyy-mm-dd hh24:mi:ss')";
}


sql += " group by toolName";


解决办法:直接比较时间会报错to_date to_timestamp,就是不能直接比较

你可能感兴趣的:(Orcale时间比较,sql查询比较orcale时间)