
可以比较,具体比较方法如下:
[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')
时间类型可以比较大小,但是日期格式需要转成字符串,或者字符串转成日期来比较
and TIME <= to_date('20130104', 'yyyymmdd')修改为
and TIME <= to_date('20130104235959', 'yyyymmddHH24MISS')
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)