当前位置: 代码迷 >> Web前端 >> 查询两个日期其间的数据
  详细解决方案

查询两个日期其间的数据

热度:104   发布时间:2013-08-21 10:42:06.0
查询两个日期之间的数据
查询输入区段时间内数据,包含两端。


1、起始日期、终止日期必须同时填写,或者同时不填写:
var csrqStart = document.getElementById("arVO.csrqStart").value;
var csrqEnd = document.getElementById("arVO.csrqEnd").value;
var t1 =(csrqStart != null && csrqStart != '');
var t2 =(csrqEnd != null && csrqEnd != '');
if(1==(t1^t2)) {
	parent.parent.parent.notifyWarn('起始、结束日期只能都填写或者都不填写!');
	return false;
}
if(t1 && t2) {
	var time1 =new Date(csrqStart).getTime();
	var time2 =new Date(csrqEnd).getTime();
	if(time1>time2) {   
		parent.parent.parent.notifyWarn('结束日期必须大于起始日期!'); 
		return false;   
	}   
}


2、MyBatis查询语句:
<if test="csrqStart != null  
          and csrqStart !='' 
          and csrqEnd != null  
          and csrqEnd !=''  ">
   A.CSRQ BETWEEN to_date(#{csrqStart},'yyyy-mm-dd') 
   AND to_date(#{csrqEnd},'yyyy-mm-dd')
</if>


3、大于or小于查询语句:
SELECT * FROM T_SHSJGL_AR A
WHERE A.CSRQ >to_date('2007/03/27','yyyy-mm-dd');
  相关解决方案