Looping Datetime


I have a row of data like the picture above, I want to create a new datatable where the number of rows is 42 with each row containing months and years starting from the row of data for example Jan 2020, Feb 2020, and so on. what is the best way to create the datatable?

You could-

  1. build a new dataTable
  2. Add a dataRow to the new dataTable
    in the ArrayRow property you would use something like
    {row.item(6).toString(“MMM”), row.item(6).Year.toString}

Proof (and please let me know if you need more help!):

image

the result is like the picture above, how to bring up January, February for 42 periods?

@ochyalrin Assuming that you want the result in Excel file, Can you maybe provide the Sample Input excel file data and the Output for that Sample data according to you. In that way we can understand the operation and solve the problem much faster if at all possible.

1 Like

I think we need to take a closer look at the Locals. if row.Item(6) is equal to January 2020, what variable is giving you February 2020?

Ideally you would put the “Add Data Row” Activity in a loop and iterate through each row while taking the dateTime value and passing that value into the ‘Add Data Row’ Activity.

Assuming you want a dataTable with only 1 column- the arrayRow property would be {row.item(6).tostring(“MMM”) + " " + row.item(6).year.toString}

if you iterate to the next row and row.item(6) gives you feb 2020, do a ‘for each row’ with an ‘add data row’ in it