• You are trying to store the value 18 in a month, which is not possible of course.

    You can either use CONVERT to convert the string to a datetime. You only need to specify the correct format.

    DECLARE @date DATETIME= CONVERT(DATETIME,'18-06-2014 11:38:46.050',105); -- apparently the Italian format

    SELECT CAST(@date AS VARCHAR);

    Or you can use SET DATEFORMAT to override the implicit date formatting.

    SET DATEFORMAT dmy;

    DECLARE @date DATETIME= '18-06-2014 11:38:46.050';

    SELECT CAST(@date AS VARCHAR);

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP