Search code examples
ssisssis-2008

How to convert CYYMMDD to YYYY-MM-DD in SSIS?


I have data in a CYYMMDD date format which I need to convert into YYYY-MM-DD in SSIS Package. How to achieve this? Any help will be appreciable.


Solution

  • Suppose your CYYMMDD column is called cdate and let's call the transformed date ydate then you may need a Derived Column transformation with this expression:

    LEFT(cdate,1) == "0" 
    ? "19" + SUBSTRING(cdate,2,2) + "-" + SUBSTRING(cdate,4,2) + "-" + RIGHT(cdate,2) 
    : "20" + SUBSTRING(cdate,2,2) + "-" + SUBSTRING(cdate,4,2) + "-" + RIGHT(cdate,2)
    

    result:

    enter image description here