T-SQL Tutorial

Msg 241 Level 16 - Conversion failed when converting date and/or time from character string


On Transact SQL language the Msg 241 Level 16 - Conversion failed when converting date and/or time from character string. This means that the format date is incorrect.

Msg 241 Level 16 Example:





Invalid statement:

USE model;
GO
DECLARE @date date= '21-09-2014';
SELECT @date AS 'My date';
GO

Message
Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string.

Correct statement:

USE model;
GO
DECLARE @date date= '09-21-2014';
SELECT @date AS 'My date';
GO

My date
2014-09-21

Other error messages: