oracle中date类型的比较

字段 dtCreatDates 在oracle中为DATE类型,java类中为 DATE类型.


private Date dtCreatDate;


现在从条件框返回一个格式为"2015-06-03"的String类型的字符串,在service中用sql语句进行日期的条件查询.


那么需要将string类型转换为日期类型,再与日期类型进行比较...


代码如下:


Service:
String hql = "SELECT COUNT(*) FROM Instructions  ";
                hql =hql+where;

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')";
	}
int count = objSvr.getCount(tWhere);


打印的语句如下:

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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值