I have a query which returns all of the rows for three days ago:
SELECT * FROM table2
WHERE CONVERT(date, given_schedule)
= CONVERT(date, DATEADD(d, -3, GETDATE()))
But I want to know limit the rows to only the hour relative to the current time. So for example, it is currently after 9:00 PM then I only want to retrieve the rows that occurred three days ago and between 9:00 and 10:00 PM.
To address @Habo’s point, you could also do:
This is, of course, most useful if there is actually an index with
given_scheduleas the leading column.