Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

MMM DD YYY to YYYYMMDD

$
0
0
I have a column that is a datatype varchar(12) and is displaying dates as MMM DD YYY (i.e. "Jul 11 2014"). I need to get it into a yyyymmdd format (i.e. "20140711"). I have tried to cast/convert/substring and cannot get. I get stuck with dashes(i.e. "2014-07-11") when using either of the following codes below. select (cast(substring(A1.Coll_DT,8,4)+substring(A1.Coll_DT,1,3)+substring(A1.Coll_DT,5,2)as DATE))from a1or select (CONVERT(date,a1.coll_dt,112)) from A1I can't figure out how to get it into an INT datatype. I thought I could use 'select CAST(convert(date,a1.coll_dt,112)as int) from A1', but get a message saying it's not allowed. Any help would be extremely appreciated

Viewing all articles
Browse latest Browse all 3145

Trending Articles