Home Forums SQL Server 2008 SQL Server Newbies Converting date column that is a varchar data type to a datetime data type RE: Converting date column that is a varchar data type to a datetime data type

  • Eric M Russell (4/10/2015)


    From what you recall, basically what was the DDL; was it essentially just an integer column?

    It was a VARCHAR built from:

    1 - 4 = DATEPART(yyyy,GETDATE)

    5 - 9 = VARCHAR(5) composed of

    a) the last 5 chars of the previous matter number CAST as an INT '02014' --> 2014

    b) formatted back into a right-justified, zero-masked VARCHAR --> '02014'

    Sigerson

    "No pressure, no diamonds." - Thomas Carlyle