find rows that fall between a day and time of the week in sql server
- by Corgalore
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?