Date param between two dates
<p>Hi,</p>
<p>I've got a report with query in open() script like this:</p>
<pre class="_prettyXprint _lang-nocode">
" select "+
" ce.name, "+
" ceOGV.name, "+
" sum(gr.receiveDoc),0 "+
" from PackStatus ps, PackVariable pvZap,PackVariable pvOGV, GossrvcRequest gr, GossrvcDocPackage gdp,CardElement ce,CardElement ceOGV "+
" where "+
" ps.status.code = 'OGVrquestExec' and "+
" ps.id=pvZap.packStatus.id and "+
" pvZap.definitionId = 'Zapros' and "+
" ps.id=pvOGV.packStatus.id and "+
" pvOGV.definitionId = 'Gos_Org' "+
" and ps.ddl !=null and "+
" ps.begins >= :stDate and ps.begins <= :edDate and" +
" ps.ends >= :stDate and ps.ends <= :edDate " +
" and ps.ddl> ps.deadLine "+
" and pvZap.longValue = gr.id "+
" and gdp.id = ps.gossrvcDocPackage.id "+
" and ceOGV.id = pvOGV.stringValue and "+
" ce.id = gdp.serviceId and (gdp.testPackage = false or gdp.testPackage is null) group by ce.name, "+
" ceOGV.name "
</pre>
<p>and when I'm building report with the same start and end dates, e,g, 01.07.2014 - the report is empty, but for 2 day interval - it's ok.</p>
<p>I think the problem is in this lines:</p>
<pre class="_prettyXprint _lang-nocode">
" ps.begins >= :stDate and ps.begins <= :edDate and" +
" ps.ends >= :stDate and ps.ends <= :edDate " +
</pre>
<p>In table PackStatus ps the begins and ends dates are stored as timestamp, so there is the time, not only date. And report gives params stDate and edDate are like 01-07-2014-00:00:00 as I know. How can compare dates correctly? Maybe add one day to end date?</p>
<p>Thanks.</p>
<p> </p>
<p>[update] I added in open script this lines</p>
<pre class="_prettyXprint _lang-nocode">
cal = Packages.java.util.Calendar.getInstance();
cal.set (Packages.java.util.Calendar.HOUR_OF_DAY,00);
cal.set (Packages.java.util.Calendar.MINUTE,00);
cal.set (Packages.java.util.Calendar.SECOND,0);
cal.set (Packages.java.util.Calendar.MILLISECOND,0);
stDate=cal.getTime();
cal.set (Packages.java.util.Calendar.HOUR_OF_DAY,23);
cal.set (Packages.java.util.Calendar.MINUTE,59);
cal.set (Packages.java.util.Calendar.SECOND,59);
cal.set (Packages.java.util.Calendar.MILLISECOND,0);
edDate = cal.getTime();
</pre>
<p>But the data in my report become incorrect for other time periods.</p>
<p> </p>
<p>[update2]</p>
<p>This piece of code fixed my problem</p>
<pre class="_prettyXprint _lang-nocode">
cal = Packages.java.util.Calendar.getInstance();
cal.setTime(stDate);
cal.set (Packages.java.util.Calendar.HOUR_OF_DAY,00);
cal.set (Packages.java.util.Calendar.MINUTE,00);
cal.set (Packages.java.util.Calendar.SECOND,0);
cal.set (Packages.java.util.Calendar.MILLISECOND,0);
stDate=cal.getTime();
cal.setTime(edDate);
cal.set (Packages.java.util.Calendar.HOUR_OF_DAY,23);
cal.set (Packages.java.util.Calendar.MINUTE,59);
cal.set (Packages.java.util.Calendar.SECOND,59);
cal.set (Packages.java.util.Calendar.MILLISECOND,0);
edDate = cal.getTime();
</pre>