Tuesday, June 14, 2011

Converting Varchar to Date format

declare @dt date
if(isdate('Thursday, April 01, 2010') = 0)
begin
set @dt = convert(date, substring('Thursday, April 01, 2010',CHARINDEX(',', 'Thursday, April 01, 2010') + 1,len('Thursday, April 01, 2010')), 103)
end
print @dt

No comments: