1.11M Members

selecting data between a time range

 
0
 

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.

 
0
 

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'
 
0
 

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].

 
0
 

It's still not clear. How do you store the date? Do you store it at all?

 
0
 

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.

 
0
 

Does this mean that the date part is irrelevant and you're only working with the time part?

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: