Conversion failed when converting datetime from character string

This applies to T-SQL.

When creating dynamic SQL query, you need to generate SQL string statement.

Thus, when you do that, SQL requires that the date is to be converted to string format.

This error occurs when SQL tries to convert the date to string intrinsically but failed.

The solution is to convert the date extrinsically.

Refer to all date formats of T-SQL.