title: Set dynamic variable day in SSIS Package
body: <p>I hope you can help me on this! I really appreciate the help from here!</p>
  
  <p>What I'm trying to do is create SSIS package to import a .TXT delimited file into a database. The procedure for doing this with a static file is clear in my mind, but the thing here is that the import has to be done using a file from yesterday, every day.
  The file name has this structure: "Informe_De_Recupero_D141027" (with the date part being "141027").</p>
  
  <p>I've created a variable on the SSIS package called FileDateName with the following expression: </p>
  
  <pre><code>RIGHT( "00" + (DT_STR, 4 , 1252)DATEPART( "year" , GETDATE() ),2) + "" 
  + RIGHT( "00" + (DT_STR, 2 , 1252)DATEPART( "month" , GETDATE() ) , 2 ) 
  + "" + (DT_STR, 2 , 1252) DATEPART( "day" , getdate()-1) 
  </code></pre>
  
  <p>But The -1 doesn't work in this scenario. It causes the following error: </p>
  
  <blockquote>
    <p>The data type "DT_DBTIMESTAMP" cannot be used with binary operator "-"
    the type of one or both of the operands is not supported for the
    operation. To perform this operation, one or both operands needs to be
    explicity cast with a cast operator.</p>
    
    <p>Attempt to set the result type of binary operation "Getdate()-1" failed with error code 0xc0047081
    Evaluating function "DATEPART" failed with error code 0xc0047084</p>
  </blockquote>
  
  <p>How can I solve it? Could you please give me another solution, maybe?</p>
  
  <p>Thanks in advance!!</p>