CAST AND CONVERT T-SQL
Posted on 2012-03-29
Trying to take a two step process down to one step. I'm if got a date stored as 20110119(YYYYMMDD), this date represents Jan 19, 2011.
Currently, I'm using a data step approach using a WITH statement.
WITH T1 AS
Select CAST(FromDate AS DATE) AS FmDt
/* this takes it from 20110119 to 2011-01-19 */
Select CONVERT(NVARCHAR(110), T1.PgmFmDt, 110) AS PgmFmDt
/* this takes it from 2011-01-19 to 01-19-2011 */
What I really want to do is go direct from 20110119 to 01/19/2011, notice I'm also want to replace the - with /.