conversion of a varchar datatype to a datetime datatype resulted in an out-of-range value

sql, sql-server

Solution

Type `103` requires that you have datetimes with the European date/month order: `'dd/mm/yyyy'`

If you store month first, this may result in this error (say for `'01/13/2012'`)

If it's the case, use type `101` (`'mm/dd/yyyy'`)

It's always better to store datetimes as `DATETIME`.

Problem

The conversion of a varchar datatype to a datetime datatype resulted in an out-of-range value ``` select a.DLNO, a.NAME, b.TOPSTRING, Convert(datetime,a.DOB,103) as DOB, Convert(datetime,a.DOI,103) as DOI, Convert(datetime,b.datepushed,103) as datepushed from PLInfo_Demo a,DLInfo_Demo b where a.dlno=b.DLNO ```

Original source