Lets say I have a table with a feild called submit_time (as seen below) and I have a web interface where users are able to (at the click of a button...well actually at the click of selections from drop down menus) view all records that were "submitted" between a certain time (i.e the user is able to specify a time range...a "start range" and a "stop range"). The ting is the user is allowed to select from HOUR , MINUTE or SECOND or ANY combination of thoze .
EXAMPLE a user is able to specify a time of ::12 TO 19:__:20 (where under score means the user did not select anything....which is valid as long as they at least select one of the options in the "start range" and at least one of the option in the "stop range")
NOTE that the time is specified as HH:MM:SS
Lets say I have this in my DB:
+------------+
| submit_time |
+------------+
| 16:03:46 |
| 16:03:59 |
| 16:04:02 |
| 16:06:09 |
| 16:06:12 |
| 16:06:30 |
| 16:06:36 |
| 16:07:22 |
| 16:07:25 |
| 16:07:55 |
| 16:09:31 |
| 16:09:37 |
| 16:09:55 |
| 16:09:59 |
| 16:10:16 |
| 16:10:20 |
| 16:10:46 |
| 16:10:56 |
| 16:10:59 |
| 16:11:09 |
| 16:11:16 |
| 16:11:19 |
| 16:11:27 |
| 16:11:29 |
| 16:15:17 |
| 16:15:19 |
| 16:15:22 |
| 16:15:26 |
| 16:16:06 |
| 16:16:09 |
| 16:16:11 |
| 16:16:14 |
| 16:16:17 |
| 16:16:29 |
| 16:16:32 |
| 16:16:35 |
| 16:16:42 |
| 16:16:45 |
| 16:16:48 |
| 16:16:51 |
| 16:17:33 |
| 16:17:36 |
| 16:17:40 |
| 16:17:43 |
| 16:17:45 |
| 16:18:48 |
| 16:21:16 |
| 16:22:52 |
| 16:22:58 |
| 16:23:12 |
| 16:24:24 |
| 16:26:29 |
| 16:26:37 |
| 16:29:43 |
| 16:32:21 |
| 16:50:26 |
| 16:54:30 |
| 16:54:59 |
| 17:41:51 |
| 18:05:12 |
| 18:05:15 |
| 18:05:40 |
| 18:12:02 |
| 18:23:36 |
| 18:23:39 |
| 18:12:10 |
| 17:44:10 |
| 17:44:16 |
| 18:19:57 |
| 10:52:17 |
| 11:05:33 |
| 11:07:16 |
+------------+
Why does this query return :
SELECT * FROM details_submitted WHERE submit_time BETWEEN submit_time LIKE '__:__:12' AND submit_time LIKE '18:__:59';
Whenever I execute it in MySQL 4.0.20-standard
Suppose, also that in the same table I had the following (corresponding) dates how would I do a a query for all reccords that fall between a given submit_time and submit_date (noting that the user is able to select date jus the same way as they selected time...jus as above)
For example I want all reccords that fall within the following time range:
16::01 TO '18::00' AND between the following date: '2004--09 TO '--13'
Where submit_date is of the format YYYY-MM-DD
+-------------+
| submit_date |
+-------------+
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2004-08-05 |
| 2003-01-09 |
| 2004-08-09 |
| 2004-08-09 |
| 2004-08-10 |
| 2004-08-13 |
| 2004-08-13 |
| 2004-08-13 |
+-------------+