sqlsql-server2-digit-yeary2k

Date conversion from "JAN02/19 to 2019-01-02


How do I convert the values of a varchar(25) column from dates in the format "JAN02/19" to "2019-01-02"(YYYY-MM-DD)?


Solution

  • Perhaps something like this

    Declare @S varchar(25)='JAN02/19'
    
    Select try_convert(date,replace(@S,'/',' 20'))
    

    Returns

    2019-01-02