oracle中date类型能比较大小吗?

如题所述

可以比较,具体比较方法如下:

[java] view plain copy

    Service:  

    String hql = "SELECT COUNT(*) FROM Instructions  ";  

    hql =hql+where;  


    [java] view plain copy

    String strStartDate=ParamUtil.getString(request,"strStartDate","");//格式为:2010-05-03  

    String strEndDate=ParamUtil.getString(request,"strEndDate","");//格式为:2016-06-01  

    if(!strStartDate.equals("")){  

    tWhere+=" and dtCreatDate>=to_date('"+strStartDate+" 00:00:00','yyyy-mm-dd hh24:mi:ss')";  

    }  

    if(!strEndDate.equals("")){  

    tWhere+=" and dtCreatDate<=to_date('"+strEndDate+" 23:59:59','yyyy-mm-dd hh24:mi:ss')";  

    }  

    [java] view plain copy

    int count = objSvr.getCount(tWhere);  

    打印的语句如下:

    [sql] view plain copy

    WHERE intVirDel<>1  and dtCreatDate>=to_date('2016-06-01 00:00:00','yyyy-mm-dd hh24:mi:ss') and dtCreatDate<=to_date('2016-06-24 23:59:59','yyyy-mm-dd hh24:mi:ss')  

时间类型可以比较大小,但是日期格式需要转成字符串,或者字符串转成日期来比较

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-01-03

时间类型可以比较大小,但是日期格式需要转成字符串,或者字符串转成日期来比较