Avatar of Rickzzz
Rickzzz

asked on 

T-SQL - Convert TEXT to DATE

column DateOfBirth is varchar(08)
I need to convert that text to a date.

There are no leading 0's in that column, so Sept 20 1980 is stored as '9201980'

I need to convert that text to a proper date, or '09/20/1980'
declare @DateOfBirth varchar(08) = '9201980'
select CONVERT(varchar,CONVERT(datetime,@DateOfBirth ,  112),121)  -- This and several variances have failed

Open in new window


Thanks in advance.
Microsoft SQL Server

Avatar of undefined
Last Comment
Rickzzz

8/22/2022 - Mon