Conversion Failed When Converting Date and/or Time from Character String Error in SQL Server

Hello everyone,

In this article I will give information about Conversion failed when converting date and/or time from character string error in SQL Server.

When you want to convert date in SQL Server, you may encounter the following error.

Conversion Failed When Converting Date andor Time from Character String Error in SQL Server

You will get an error like the one above because the datetime type does not have nanosecond precision. It will only work if you add milliseconds.

If you edit the query as follows, it will work.

DECLARE @TarihDegeri NVARCHAR(MAX) = '2022-07-19 14:00:39.0000000'
SELECT
	CONVERT(DATETIME2, @TarihDegeri)

When you run the above code again, you will see a result like below.

Conversion Failed When Converting Date andor Time from Character String Error in SQL Server

As you can see, the error has been corrected.

Good luck to everyone in business and life.

33 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!