title: SSIS Script task storing DateTime in variable
body: <p>I'm not sure why this happens, but my script task is not storing a DateTime-Value in a variable.
  This is the (till now) very basic code I've written:</p>
  
  <pre><code>[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
  public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
  {
      public void Main()
      {
          DateTime creationTime;
          DateTime modifiedTime;
          DateTime oldCreationDate = (DateTime)Dts.Variables["User::OldFileDate"].Value;
          DateTime oldModifiedTime = (DateTime)Dts.Variables["User::OldModifiedDate"].Value;
  
          Dts.Variables["User::OldFileDate"].Value = DateTime.Now;
  
          Dts.TaskResult = (int)ScriptResults.Success;
      }
  
      enum ScriptResults
      {
          Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
          Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
      };
  }
  </code></pre>
  
  <p>It's not done yet, but I wanted to check if the variable is stored or not. I checked the variables using the debugger, during runtime the varible changes, but if I look at the variable after the execution it is still the same value.
  I also checked the properties and <code>ReadOnly</code> is <code>False</code> and the Variables are also added to the package.<a href="https://i.stack.imgur.com/LW2Fn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LW2Fn.png" alt="Variables"></a> <a href="https://i.stack.imgur.com/DopYj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DopYj.png" alt="variable declaration in ssis"></a> Any Ideas on what I am doing wrong?</p>