There is an expression which I’ve build to reduce the time section out of date time and to ZERO it.
DateAdd(day, DateDiff(day, 0, PayDate), 0)
My question is in this query (pseudo code) :
select
DateAdd(day, DateDiff(day, 0, PayDate), 0),
DateAdd(day, DateDiff(day, 0, PayDate), 0) + 3
where DateAdd(day, DateDiff(day, 0, PayDate), 0) > 3
The DateAdd expressions are all the same.
Here is my question :
- Does SQL Server re-calculate each time it sees this expression (in the
selectand in thewhereclause…)
When you use a function several times in a query, it will be called every time it is used.
The fact that you call it with the same parameters make no difference.
So yes,
DATEDIFFandDATEADDwill be called three times each.