现在的位置: 首页 > 综合 > 正文

Orcale时间比较

2013年02月12日 ⁄ 综合 ⁄ 共 468字 ⁄ 字号 评论关闭
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,就是不能直接比较

抱歉!评论已关闭.