2

I want to create a SSIS package which will have two data flow tasks. If today's date is startdate of the Month it should execute one dataflow task(which actually has a month end report), else then it should execute another dataflow task(which is a weekly report). Can anyone please let me know how to attain this one.

Thanks,

vinisha9
  • 91
  • 1
  • 2
  • 8
  • What have you done so far? I suggest you create a variable to hold the day of the month (an integer) then drop on an expression task https://msdn.microsoft.com/en-us/library/hh213137.aspx and in that, use an expression that gets the day of the month. That's a start. You can work all of this out with google – Nick.Mc Nov 04 '16 at 14:38

1 Answers1

1

1.) Create a variable of datatype boolean in the package scope. I named mine startDate in this example.

enter image description here

2.) Create a script task with two precedent constraints. One going to the data flow task when it's the beginning of the month and the other when it's false. enter image description here

3.) Edit the script task and add the startDate variable into ReadWriteVariables. enter image description here

4.) Click on "Edit Script" and insert the following into the method (you can uncomment the message box to make sure it works correctly when you execute the package) and don't forget to save:

DateTime value = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);

        if (DateTime.Today == value)
        {
            Dts.Variables["User::startDate"].Value = bool.Parse("True");
        }
            Dts.Variables["User::startDate"].Value = bool.Parse("False");

        //MessageBox.Show(Dts.Variables["User::startDate"].Value.ToString());

5.) After that, all you have to do is edit the precedence constraints going to each DFT. enter image description here enter image description here

Jonathan Porter
  • 1,365
  • 7
  • 34
  • 62