Question : Conversion of varchar(255) to Datetime

Hi Experts,

I have column in a table that I need to convert to datetime so that I can use datediff function to get all the rows that are having values older than 9 months. Can anybody assist me in converting the varchar to datetime so that i can run datediff?

The values in the column are as follows 20021114 i.e YYYYMMDD

Regards,

Answer : Conversion of varchar(255) to Datetime

well you can try

select case when isdate(column) = 1 then convert(datetime, column, 112) else '1900-01-01' end

Random Solutions  
 
programming4us programming4us