Parse a date from unformatted text in SQL

前端 未结 4 1506
执笔经年
执笔经年 2020-12-11 02:44

I\'m trying to figure out an elegant way to get a date from a text column that has data like this \"YYYYMMDD\"...so we might see \"20060508\" as a value in the column, which

4条回答
  •  难免孤独
    2020-12-11 03:43

    try:

    SELECT REPLACE(CONVERT(varchar(30),CONVERT(datetime, '20060508'),107),' 0',' ')
    

    output:

    -------------------
    May 8, 2006
    
    (1 row(s) affected)
    

提交回复
热议问题