Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:54:27+00:00 2026-06-13T23:54:27+00:00

I have a For Loop Container using a date as InitExpression ( @Load_Date )

  • 0

I have a For Loop Container using a date as InitExpression (@Load_Date) but the value is in number format (20120229) and I need it that way because I cannot modify it.

Now, I would like to set the AssingExpression value in such a way that the @Load_Date variable can be incremented as it is a date. In other words the number value 20120229 assigned to the variable @Load_Date should increment to 20120301 because that is the next logical date.

How can I achieve this within the For loop container in SSIS package?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:54:28+00:00Added an answer on June 13, 2026 at 11:54 pm

    Here is a possible way that you can do this. The sample below uses SSIS 2012.

    Let’s say that you have two variables that contain the minimum and maximum date ranges but they are stored in numerical format and you still want those values to obey the date rules.

    Declare the following variables:

    • MinInteger – This variable of data type Int32 will store the minimum date value in numerical format. If you are using SSIS 2012, it is advisable to create this as a parameter so you can easily configure the values during runtime.

    • MaxInteger – This variable of data type Int32 will store the maximum date value in numerical format. If you are using SSIS 2012, it is advisable to create this as a parameter so you can easily configure the values during runtime.

    • MinString – This variable of data type String will convert the minimum date value in number format to string so that it is easier to work with in splitting the values to create the date format. Set the expression to (DT_WSTR, 10) @[User::MinInteger]

    • MaxString – This variable of data type String will convert the maximum date value in number format to string so that it is easier to work with in splitting the values to create the date format. Set the expression to (DT_WSTR, 10) @[User::MaxInteger]

    • MinDate – This variable of data type DateTime will split the string value of minimum date to formulate the date value. Set the expression of this variable to the following:

    (DT_DATE)(SUBSTRING(@[User::MinString], 1, 4) + “-” + SUBSTRING(@[User::MinString], 5, 2) + “-” + SUBSTRING(@[User::MinString], 7, 2))

    • MaxDate – This variable of data type DateTime will split the string value of maximum date to formulate the date value. Set the expression of this variable to the following:

    (DT_DATE)(SUBSTRING(@[User::MaxString], 1, 4) + “-” + SUBSTRING(@[User::MaxString], 5, 2) + “-” + SUBSTRING(@[User::MaxString], 7, 2))

    If you are using SSIS 2008 R2 or previous versions, you need to set the EvaluateAsExpression property of the last four variables mentioned above to True.

    • Loop – This variable of data type DateTime will be used to loop through the date values in the For loop container.

    Variables

    Configure the For loop container as shown below:

    • InitExpression: @[User::Loop]=@[User::MinDate]
    • EvalExpression: @[User::Loop]<=@[User::MaxDate]
    • AssignExpression: @[User::Loop]=DATEADD("dd", 1, @[User::Loop])

    The sample increments the values by 1 day but you can configure this however you would like to. You can also store the DATEPART and Increment number in another variable/parameter for easier configuration.

    For loop

    I have placed a Script Task within the For loop to illustrate the sample package execution. Script task has the variable User::Loop set to ReadOnlyVariables and contains the following C# code.

    public void Main()
    {
        MessageBox.Show(string.Format("Current loop variable value: {0}", Dts.Variables["Loop"].Value.ToString()));
        Dts.TaskResult = (int)ScriptResults.Success;
    }
    

    If the MinInteger is set 20120229 and MaxInteger is set to 20120302, the package will display the following values during the execution.

    Hope that helps.

    Output 1

    Output 2

    Output 3

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty new to jQuery/JS. But I have loop in jQuery where I would
I have a loop that enters each non-empty text field into a database: foreach
I have a loop in razor which generates a template a number of times.
I have a package i am using the foreach loop to loop through the
Using Observer pattern. I have a class, called Monitor for example, that is monitoring
I have a container of large objects that are expensive to copy. I must
Hi I have installed the PowerShellPack and I am using the FileSystem watcher module,but
So I have an IList of business entities that I loop through in a
I have a text file dump that I need to convert to a delimited
I have a loop that I'm trying to parallelize and in it I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.