title: SSIS Expression to get last day of the month given YYYYMM
body: <p>I am trying to figure out how to get the last day of the month given with a SSIS Expression.</p>
  
  <p>I receive the column as an Integer, then added a Data Conversion step to convert the YYYMM to a date format.
  Then on derived column, my expression is: </p>
  
  <p><code>REPLACE((DT_WSTR,10)(DT_DBDATE)DATEADD("D",-(DAY(DATEADD("M",1,[Copy of MONTH]))),DATEADD("M",1,[Copy of MONTH])),"-","")</code> </p>
  
  <p>And on final table I am getting the value 24520504.</p>
  
  <p>Example: I am getting the value for the derived column from an .xls file. 
  On that file, I use the column MONTH and it is an Integer (example: 201711).
  On the final table it is an Integer too, but it has the last day from 201711 (example: 20171131)</p>
  
  <p>EDIT: After your help, I reformulate my expression but I still get an error:</p>
  
  <pre><code>REPLACE((DT_STR,10,1252)DATEADD("d",-1,DATEADD("m",1,(DT_DBDATE)(DT_STR,6,1252)[MONTH])),"-","")
  </code></pre>