I need to query a database table hosted on an MSSQL server.
The request is as follows:
select *
from tableA
where createdOn between @startDate and @endDate
The variable types @startDate and @endDate are the date and time. If @endDate matches the current date and @startDate is equal to the date once a month before, I thought we could make a request either as
declare @startDate datetime
declare @endDate datetime
set @startDate = DATEADD(month,-1,GETDATE())
set @endDate = GETDATE()
select *
from tableA
where createdOn between @startDate and @endDate
or
select *
from tableA
where createdOn between DATEADD(month,-1,GETDATE()) and GETDATE()
I thought the first request would be faster than the second, because in the second request we call the functions in the where clause. I wrote both versions of my request, and I executed them too. However, I did not notice significant differences in performance.
Can someone explain to me why I have not seen any changes. Perhaps the idea that the first request should be faster than the second was false. Please let me know what matters, why not.
.