Wow, depending on the number of rows, performance could be an issue. Now using your examples from above (I know you said I didn’t have to, but I am not that clever), your queries should look like this:
FROM test f
(f.START_TIME >= TIMESTAMP ‘2007-04-13 00:00:00’ AND f.START_TIME < TIMESTAMP ‘2007-07-20 00:00:00’ )
<b>and start_time between to_timestamp(‘2007-04-13 02:00:00′,’YYYY-MM-DD HH24:MI:SS’)
and to_timestamp(‘2007-04-13 06:00:00′,’YYYY-MM-DD HH24:MI:SS’)
and to_char(start_time,’HH24′) < > ’22’ </b>
Be aware that since we are using a function on the start_time column in the last where critieria, the index on start_time (if there is one) will not be used. You can rewrite the query to look like the between statement prior to the to_char line.
Hope this helps…
To exclude certain days, you could also use the “to_char” function with a single ‘D’ as the format.
For example, to exclude Wednesday and Friday, the condition should look like this:
<pre>and to_char(f.start_time,’D’) not in (4,6)</pre>