Friday , March 29 2024

Conversion failed when converting date and/or time from character string

 

You receive this error when you try to convert a string that is a not compatible with the datetime data type to a datetime.

It usually occurs when you want to insert a string that is not compatible with the datetime data type into a column of datetime data type.

For example, with the help of the following script, let’s create a table named datetimeconvert in the TestDB database and try to insert a value as follows.

As you can see, we received the error we expected. We received this error because we changed the order of the columns created_date and login_name when inserting. When we change the script as follows, it will be completed successfully without error.

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories