If you’re getting SQL Server error Msg 8116 with text that reads Argument data type date is invalid for argument 1 of substring function, it’s because you’re passing the wrong data type to a function – in this case, the SUBSTRING()
function.
You could also see the same error (Msg 8116) in many other contexts – it’s not limited to the SUBSTRING()
function.