We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,329 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

selecting data between a time range

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.

2
Contributors
5
Replies
1 Day
Discussion Span
1 Year Ago
Last Updated
7
Views
gunsofnavarone
Newbie Poster
3 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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'
smantscheff
Nearly a Posting Virtuoso
1,297 posts since Oct 2010
Reputation Points: 321
Solved Threads: 270
Skill Endorsements: 8

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

gunsofnavarone
Newbie Poster
3 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

smantscheff
Nearly a Posting Virtuoso
1,297 posts since Oct 2010
Reputation Points: 321
Solved Threads: 270
Skill Endorsements: 8

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.

gunsofnavarone
Newbie Poster
3 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

smantscheff
Nearly a Posting Virtuoso
1,297 posts since Oct 2010
Reputation Points: 321
Solved Threads: 270
Skill Endorsements: 8

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1057 seconds using 2.66MB