In Azure Synapse Analytics, I would like to use the pipeline function to set a variable of type array for the date from 12 months ago to current date. The date in the variable is the first day of each month. For example, a variable to be created this month might look like this
['2022-08-01','2022-09-01','2022-10-01','2022-11-01','2022-12-01','2023-01-01','2023-02-01','2023-03-01','2023-04-01','2023-05-01','2023-06-01','2023-07-01','2023-08-01']
And the variables to be created in September will be like this
['2022-09-01','2022-10-01','2022-11-01','2022-12-01','2023-01-01','2023-02-01','2023-03-01','2023-04-01','2023-05-01','2023-06-01','2023-07-01','2023-08-01','2023-09-01']
Any answer would be helped. Thank you.
You can use for each and append variable activity as below.
First, use
Set variableto create empty array as below.Empty date array
Next, create
ForEachactivity and addAppend variableactivity inside it.Here, I given the items in range between
0to13since you want dates for last 12 months. If you have this number in any variable or parameter add that in second argument of this range function.Make sure to enable
SequentialNext, inside append variable add expression as below.
Here, in the Name field choose the empty array variable you created initially. And in value field add above expression given.
Next, create new
Set variableand create new array variable then give the value of the date array variable previously created.Output:
Note: Give the date according to your requirement, but make sure not give
29,30and31as these dates will not be in every month.