I am working on a query that will be an automated job. It needs to find all the transactions between 8 PM and 8 PM for the last day. I was thinking of doing something like
This will also work:
DECLARE @start_date datetime DECLARE @end_date datetime SET @start_date = LEFT(CONVERT(nvarchar, DATEADD(DAY, -2, GETDATE()), 120), 11) + N'20:00:00' SET @end_date = @start_date + 1 select @start_date, @end_date
Although cyberkiwi's answer is very clever! =)