SQL Server conversion failed when converting date and/or time from character string.

Recently, I was inserting a date in a table in SQL Server, and after executing the insert query, I got this error SQL Server conversion failed when converting date and/or time from character string.

SQL Server conversion failed when converting date and/or time from character string.

I executed the SQL query below to insert a record in MyTable.

Insert Into MyTable(LastDate) Values ('2025-02-28');

After executing the query below, I got this error: Check the screenshot below for your reference.

SQL Server conversion failed when converting date and/or time from character string.

Solution

The reason for this error is that the date I am trying to enter is “2025-02-29,” and this is not a valid date because in February 2025, the last day is the 28th, and there is no 29th date in that month, so I got this error.

If I try changing the date to 28th or any other valid date with the same insert query, the record gets inserted successfully.

Insert Into MyTable(LastDate) Values ('2025-02-28');

The above query executed successfully without any issues, and the record was inserted in the table without any issues, as shown in the screenshot below.

SQL Server conversion failed when converting date and/or time from character string

The key point here is always to ensure that you insert a valid date into the SQL Server table; otherwise, this type of error will appear.

Video Tutorial

You may also like the following articles.