Hi

I have a problem while converting the char to datetime type in MSSQL Server 200/2005.

I want to retrieve the date values from table in datetime data type in a particular format like 'yyyydd' or 'yyyy/dd' similar to oracle's TO_DATE function.

For this I tried with following query,

SELECT CONVERT(datetime, CONVERT(varchar(6), date1, 112), 112) from sql_dm1

But I got the following error while executing the above query:
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

Please help me in this regard.

Thanks
Sridhar