Create two pipeline variables, say currentDate and maxDate, and assign your @min_date and @max_date to them respectively.
The Until activity will loop until the currentDate is greater than or equal to maxDate. The expression for the until condition will be something like @greaterOrEquals(variables('currentDate'), variables('maxDate')).
The set variable activity will be used to increment currentDate by 30 days. You can use an expression like @adddays(variables('currentDate'), 30) to set the currentDate variable.
Inside the loop, you can add other activities that you want to perform for each incremented date.
how to loop increment of 30 days...
I have two dates: @min_date as date @max_date as date In ADF, how can I loop through the above dates but in the increments of 30 days? for example start of loop: @min_date next: @min_date + 30 days --> something like dateadd(day, 30, @min_date) next 30 days next 30 days ... until it reaches @max_date Thank you
Azure Data Factory
2 answers
Sort by: Most helpful
-
Amira Bedhiafi 41,111 Reputation points Volunteer Moderator2024-01-17T13:13:48.16+00:00 -
Chakaravarthi Rangarajan Bhargavi 1,200 Reputation points MVP
2024-01-17T12:34:57.3466667+00:00 Hi arkiboys, Thank you for the question! Please check as below if it helps: In Azure Data Factory (ADF) expressions, you can achieve this by using a
untilactivity along with expressions for date manipulation. Here's a sample expression for your scenario:@activity('YourUntilActivity').output < @max_dateIn the above expression,
@activity('YourUntilActivity').outputrepresents the current date in the loop. You would initialize this value with@min_date. Inside the loop, you can update the date using the expression:@addDays(activity('YourUntilActivity').output, 30)Make sure to set up an
untilactivity with the mentioned condition and use this expression to update the date in each iteration. This will loop until the date is less than@max_datewith increments of 30 days. Please look at the below reference for more understanding about the 'until' https://learn.microsoft.com/en-us/azure/data-factory/control-flow-until-activity Hope this answer helps you with solution! Please comment below if you need any assistance on the same. Happy to help! Best Regards, Chakravarthi Rangarajan Bhargavi -Please kindly accept the answer and vote 'Yes' if you feel helpful to support the community, thanks a lot.