How to add new column into a datatable

Hi all,

Currently I have the Excel dataset with a date column in format (“yyyy-MM-dd hh:mm:ss”), you may see below screenshot for your reference:

image

What I trying to achieve is add one more column or replace the existing column in date format (“yyyy-MM-dd”), if I do it in manual way will use the excel formula ("=DATE(YEAR(F2),MONTH(F2),DAY(F2))") to extract the desired date format.
Do you guys have any idea how UiPath can achieve this?

A sample output should looks like below, thanks:
image

1 Like

Hi @makwan ,

You can achieve the same way you mentioned above.

1.Use excel application scope and enter your excel file path.

2.Inside use read range activity to read the data into datatable DT. Use the following expression to get row count.

Row count = DT.rows.count

  1. Use write cell activity and write header value input G1 → value is your column name short date.

  2. Use one more write cell activity and enter the formula.

  3. Now use auto fill range

Input → G2

Fill range → G2:G+Row count

Auto fill range help you to auto fill the formula to entire column.

I hope above steps to achieve your requirement. Thanks.

An alternate method would be to read the sheet into a datatable, add the column to the datatable, fill it with values, and then write back to the sheet. This would result in actual values in the sheet, not formulas.