Software⏱️ 2 min read📅 2026-05-31

How to Fix: Conversion failed when converting date and/or time from character string while inserting datetime

Cannot convert varchar to datetime error when inserting values into a datetime field in SQL Server.

Quick Answer: Use the CONVERT function or the TRY Convert function to explicitly convert the character string to a datetime value.

The error message 'Cannot convert varchar to datetime' occurs when SQL Server is unable to successfully convert a character string into a DateTime data type. This issue often arises when the format of the date and/or time in the input string does not match the expected format.

🔍 Why This Happens

  • [Cause]

🔧 Proven Troubleshooting Steps

Method 1: Using the Convert Function

  1. Step 1: Use the CONVERT function to explicitly convert the date and time string to a DateTime data type. For example, use CONVERT(datetime, '21-02-2012 6:10:00 PM');

Method 2: Using the TRY_CONVERT Function

  1. Step 1: Use the TRY_CONVERT function to attempt a conversion and handle any errors that may occur. For example, use TRY_CONVERT(datetime, '21-02-2012 6:10:00 PM');

🎯 Final Words

By applying these methods, you can successfully resolve the 'Conversion failed when converting date and/or time from character string while inserting datetime' error in SQL Server.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions