How can i add column to existing data table to get Ageing days

Hi,

I am new to UiPath and programming. Can someone help me in addressing the below query:

How can i add column to existing data table validating with Date column. As per below

DemandID RequiredBy DemandStatus Ageing

123456| 25 Dec 2018 Not Done I need days difference from B col(RequiredBy to Date.Now
654321 01 Feb 2019 Done
231654 01 Feb 2019 Done
564321 01 Feb 2019 Done
102020 01 Feb 2019 Done
123333 02 Jan 2019 Not Done

Hi @mohammed.khan39

Have you tried using the activity add data columns

Thanks for the prompt response.

I tried adding data column activity. After that I have to give expression to fetch the ageing difference from today. I dont know which activity to use further

@mohammed.khan39

Let us take you are having a dataTable dta
Now Add Column Ageing to dta by using Add Data Column Activity.

Now run For Each row for dta

Now Inside ForEach, Use One Assign Activity.
row(“Ageing”)=(DateTime.Now-DateTime.ParseExact(row(“RequiredBy”).Tostring,“dd MMM yyyy”,System.Globalization.CultureInfo.InvarientCulture)).Days.ToString

Regards,
Mahesh

1 Like

Thank you mahesh, However I am getting error when i use assign activity…

pls let me know is it work for u or not
u has to use todays date as i have send my project wf image

This error is because the spelling of Invariant is wrong as @MAHESH1 is mentioned, that’s why you are getting that error. “InvariantCulture” is the correct one!

Thanks Akhil!! It worked. But getting below error… Not sure where went wrong…

Untitled

@mohammed.khan39

I think Your Date Format is not In the Given Format for Some of the rows.

Regards,
Mahesh

Now I am getting below error in Add data column Activity. Please advise!

Also declared “DemandAgeing” new column as String. Is this correct?

Also, The column name is taking as “Column1” though I gave “DemandAgeing” and date format is not taking as declared.

Untitled1

DemandAgeing is your variable na…
If it is then have u put the default value?

yes! DemandAgeing is declared as String Variable. But not given any default value.

Then it will take it as Column 1
Either you directly write the column name or set an default value

how did you solve this?

I just started working on it… will let you know in sometime

Hello @mohammed.khan39
you are getting this error because your datatable DT is not initialized…
move add data column activity after assign activity ( where you are assigning DT = ExtractDataTable…)

I got it… might help you…Main.xaml (10.8 KB)

Hi,

Please find the below workflow. Can someone please someone correct and send back.
Thank you for your assistance.

First Assign activity contain DT=ExtractDataTable.Select(“DemandStatus=‘Open / Not Mapped’”).CopyToDataTable.

Add Data Column same as above. Scroll the page up to view.

@mohammed.khan39
your workflow look fine…
just make sure when you adding data column [DemandAgeing], its data type is of string.