I have an academic scenario that I would like to know how to analyze.
DECLARE @date DATETIME
SET @date = getDate()
SET @date = DATEADD(DAY, DATEDIFF(DAY, 0, @date-3), 3)
This will round the date to Thursday.
What I have been questioned is evidence in which there are implicit CAST.
These are three places where I assume this should happen ...
DATEADD(
DAY,
DATEDIFF(
DAY,
0,
@date-3
),
3
)
Perhaps, however, since 0they 3are constants, is this done at compile time in terms of execution?
But if there 3were INT variables, would that be different?
Is there a way to analyze the implementation plan or some other method to determine this for real?
To complicate the situation, I'm not online right now. I am trying to remotely help a colleague with this. This means that I do not have direct access to SSMS, etc.