Creating a Calculated Datatable Column Without a ForLoop

Hello everyone,

I have a data table that contains 2 columns. Customer number and Customer DOB.

I want to create 1 additional date column called DOB Plus 1 month which would be the addition of one month to the DOB original column.

So for each row, whatever the DOB value is, add one more and then populate the 3rd column called DOB Plus 1 month.

I can do this via a ForLoop and it works perfectly fine but my question is whether there is a more efficient .select method that I could use to achieve the same thing without a loop ( which can be slow sometimes).

Thank you,

@sasho1987
find starter help here:
AddCol_Plus1Month.xaml (7.3 KB)

Hi @ppr,

Would you mind explaining the code in the final Assign activity please?

(From d In dtData.AsEnumerable -> This is basically enumerating every row of the original dt

Let ad = DateTime.ParseExact(d(1).toString.Trim, “dd/MM/yyyy”,

CultureInfo.InvariantCulture).AddMonths(1).toString(“dd/MM/yyyy”)

Let ra = New Object(){d(0),d(1),ad}

Select dtEnhanced.Rows.Add(ra)).CopyToDataTable

let ad… is stroring the result for later use - parsing the string from dob col to datetime, adding 1 month, retrieve result as formatted string
let ra … constructs a new ArrayItem Object() Array
Adds ra … add a new row to dtEnha… and copies it to DataTable as result

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.