The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

Recently, I was trying to insert some date and time values into one of the SQL server tables named USAOrders, which contains 2 columns of the datetime datatype. After executing the insert query, I got this error.

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

I was executing the below insert query to insert one record to the USAOrders table.

insert into USAOrders values('02-21-2025 6:10:00 PM','01-01-2025 12:00:00 AM');

After executing the above query, I got the above error as shown in the screenshot below.

'the conversion of a varchar data type to a datetime data type resulted in an out-of-range value.'

Solution

The problem here was with the time zone setting. So I was trying to insert the datetime column value with DD-MM-YYYY format. What I have done here is, I tried inserting the date time value with the MM-DD-YYYY format.

Now, the query I execute is below.

insert into USAOrders values('02-21-2025 6:10:00 PM','01-01-2025 12:00:00 AM');

After executing the above query, I got the expected output as shown in the screenshot below and this time the data got inserted successfully without any error.

sql the conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

You may also like the following articles.