Day of year

  • Does anyone know how to convert yyyyddd into mm/dd/yyyy? ie, '2003023' (01/23/2003).

    Thank you

  • Not sure of a better way but this example is how I do it.

    declare @d char(7)

    set @d = '2003123'

    SELECT CAST(DATEADD(dd, CAST(RIGHT(@d,3) AS INT), '12/31/' + CAST((CAST(LEFT(@d,4) AS INT) - 1) AS CHAR(4))) AS DATETIME)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply