How to convert a "dd/mm/yyyy" string to datetime in SQL Server?

Posted by Sim on Stack Overflow See other posts from Stack Overflow or by Sim
Published on 2010-05-06T11:26:16Z Indexed on 2010/05/26 19:41 UTC
Read the original article Hit count: 236

Filed under:
|
|
|

I tried this

SELECT convert(datetime, '23/07/2009', 111)

but got this error

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

However

SELECT convert(datetime, '07/23/2009', 111)

is OK though

How to fix the 1st one ?

© Stack Overflow or respective owner

Related posts about tsql

Related posts about string