Conversion Failed When Converting Date and/or Time from Character String Error in SQL Server
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.
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.
As you can see, the error has been corrected.
Good luck to everyone in business and life.