Query not collecting all of data <p>I have a screen created to display a data from a query. The query is supposed collect the daily production of materials from a process. The query is below:</p> <pre><code>Select SUM(ltv.val) "CE" FROM LADLE_TAP_VALUE ltv, LADLE_TAP_ID lti where ltv.id=108 AND ltv.ladletapid =lti.ladletapid and lti.tapid IN (Select ti.TapID FROM tap_index ti WHERE ti.tapno like 'CE%' AND ti.starttime&gt;=to_date('20120426', 'yyyymmdd hh24:mi:ss') and ti.endtime&lt;=to_date('20120427 00:00:00', 'yyyymmdd hh24:mi:ss')); </code></pre> <p>The problem that I am facing is that occasionally that the starttime is near end of one day and the endtime is during the first hours of the next day. I am not sure how to make that adjustment with the time handling portion of my query. This is an issue because every day I missing production from my display that should be there.</p> <pre><code>tap_index table tapid tapno plant taphole drytap status startime endtime slagstart readytime 21437 CN121348 1 1 1 0 26-APR-12 06:00:26 26-APR-12 07:42:41 26-APR-12 06:56:34 26-APR-12 06:00:00 21436 CE121347 1 2 1 0 26-APR-12 03:21:10 26-APR-12 05:40:48 26-APR-12 04:39:27 26-APR-12 03:21:00 21435 CN121346 1 1 1 0 26-APR-12 01:48:07 26-APR-12 03:01:23 26-APR-12 02:27:34 26-APR-12 01:48:00 21434 CE121345 1 2 1 0 25-APR-12 23:27:23 26-APR-12 01:28:08 26-APR-12 00:44:09 25-APR-12 23:27:00 21433 CN121344 1 1 1 0 25-APR-12 21:18:24 25-APR-12 23:07:17 25-APR-12 22:31:04 25-APR-12 21:18:00 21432 CE121343 1 2 1 0 25-APR-12 19:55:08 25-APR-12 20:58:59 25-APR-12 20:22:39 25-APR-12 19:55:00 21431 CN121342 1 1 1 0 25-APR-12 18:09:28 25-21422 CE121333 1 2 1 0 24-APR-12 22:56:17 25-APR-12 00:29:23 24-APR-12 23:32:27 24-APR-12 22:56:00 </code></pre> <p>21421 CN121332 1 1 1 0 24-APR-12 20:49:25 24-APR-12 22:36:37 24-APR-12 21:59:30 24-APR-12 20:49:00 21420 CE121331 1 2 1 0 24-APR-12 18:15:12 24-APR-12 20:30:16 24-APR-12 19:19:42 24-APR-12 18:15:00 21419 CN121330 1 1 1 0 24-APR-12 16:06:06 24-APR-12 17:55:12 24-APR-12 17:02:33 24-APR-12 16:06:00 21418 CE121329 1 2 1 0 24-APR-12 14:04:36 24-APR-12 15:44:40 24-APR-12 14:50:33 24-APR-12 14:04:00</p>