Interesting that this does not work the same way.
select datalength(convert(varchar, getdate(), 101))
This is by design and has also been covered many times in recent QotDs. Forgetting to specify the size when declaring a local variable results in size defaulting to 1
while forgetting to specify the size when using convert - 30
. Because the 101 format means mm/dd/yyyy, totalling 10 characters, the result of the query is 10
because the default 30
is greater than that.