I need to select data available between 20:00 and 08:00 (8 PM to 8 AM).
How do I achieve this?
The column is of type TIME.
That depends on the actual format you're using. If you're not keeping track of the date, it's simply
select * from mytable where timefield <= '08:00' or timefield >= '20:00'
Ok. Maybe I have not come out clear here.
I have a list of data between diff. time periods (so, there's data between 00:00-08:00,08:00-15:00,20:00-08:00 .. so on and so forth).
I have an input field (say, 2012-01-25 21:00).
Now I wish to retrieve all data with a time window that includes 21:00.
The time periods are in two cols. [FROM_WINDOW;TO_WINDOW].
It's still not clear. How do you store the date? Do you store it at all?
This is how my table is structured: -
ID TIME_WINDOW_FROM TIME_WINDOW_TO ABC123 1899-12-30 20:00:00 1899-12-30 08:00:00 ABC456 1899-12-30 20:00:00 1899-12-30 08:00:00 ABC000 1899-12-30 08:00:00 1899-12-30 15:00:00
Now if my input is 2012-01-25 21:00, the result-set should return 2 rows.
Does this mean that the date part is irrelevant and you're only working with the time part?
We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.