I have the number 20080331.
I need to cast/convert this into a datetime so I can do a date comparison within the database. How will i go about converting this number
You need to cast to a character type first;
select cast(cast(20080331 as varchar(8)) as datetime) >>2008-03-31 00:00:00.000
SELECT CONVERT(DATETIME, CAST(20110331 AS VARCHAR(8)), 112)