Implicit conversions: Datetime-to-INT vs INT-to-Datetime
I'm having trouble understanding why the query below is considered to be converting an integer into a datetime rather than converting a datetime into an integer.
In my head I'm reading this as converting a datetime to an integer because I'm setting the datetime equal to an integer. So why would it be the opposite? I could just flip the way I think about it but my hopes were that somebody can explain this so that I can think about it in the proper manner.
I would like to know in order to get a better grip on when implicit conversions are allowed vs when they aren't allowed.
DECLARE @theDateTime AS datetime
DECLARE @theInteger AS INT = 122811
SET @theDateTime = @theInteger
from Recent Questions - Stack Overflow https://ift.tt/3l44HXd
https://ift.tt/eA8V8J
Comments
Post a Comment