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

oracle中date类型能比较大小吗?,第1张

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

[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')


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9253825.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-26
下一篇2023-04-26

发表评论

登录后才能评论

评论列表(0条)

    保存