You can delete / reset the time until 00:00, this will allow comparisons to be made today.
select DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0)
You can define variables with today's start and end dates as follows:
declare @TodayStart datetime = getdate()
declare @TodayEnd datetime = getdate()
set @TodayStart = DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0)
set @TodayEnd = DATEADD(ss, -1, DATEADD(dd, 1, @TodayStart))
Thus, your request to receive all transactions within today's date range will be as follows:
Select *from Transactions
WHERE transaction_date between @TodayStart AND @TodayEnd
source
share