find rows that fall between a day and time of the week in sql server

Posted by Corgalore on Stack Overflow See other posts from Stack Overflow or by Corgalore
Published on 2011-02-05T03:50:27Z Indexed on 2011/02/05 15:26 UTC
Read the original article Hit count: 295

Filed under:
|
|
|

I have a table of rows in MS SQL that contain a start and end day of the week, hour, and time. I need a T-SQL query that can pull rows from that table where GETDATE matches the day of week and time of those rows. Specifically, I need the query to work if a row has a day/time that starts on one day of the week and ends on the next day.

Here's the structure I'm working with:

_start_day_of_week (int) = 5
_start_hour (int) = 15
_start_minute (int) = 30
_end_day_of_week (int) = 6
_end_hour (int) = 2
_end_minute (int) = 30
_title (string) = 'My Sample Row'
_id (int) = 1

How would I retrieve this row given the current DATETIME?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about tsql