Is it possible to convert a column format date MM/dd/yyyy to dd/MM/yyyy faster

I try to convert date format MM/dd/yyyy to dd/MM/yyyy but it take too much time if i do like the example i send

mergeTest.xaml (13.1 KB)

or if faster not possible, how can i preserve excel format cell date with a merge data table.
Because when i merge source dataTable_1 (dd/MM/yyyy) with destination dataTable_2 the format in dataTable_2 become MM/dd/yyyy

Hi

Yeah it can be with this expression

stroutput = Datetime.ParseExact(Strinput.ToString, “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

And while merging make sure you have both the datatable having dates in same format and when written to excel it actually changes the format
To avoid that use a for each row activity and pass datatable dt as input

Inside the loop use a assign activity like this

CurrentRow(“date ColumnName”) = “ ‘ “+ CurrentRow(“date ColumnName”).ToString

This will retain the date format by converting the excel column as text format

Cheers @BenjenB

HI @BenjenB

Try this expression

CDate(“Column Name”).Tostring(“dd/MM/yyyy”)

Regards
Gokul

so i change :

row.item(“date”) = Convert.toDateTime(row(“date”)).ToString(“dd/MM/yyyy”)

to :

stroutput = Datetime.ParseExact(row.item(“date”).ToString, “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

dataTable_2 is in a new sheet so i don’t know where i can find the default format and in build data table the date is :
image

With build datatable activity under each column you have an option to EDIT the column and it’s type

Click on that and choose string as type and change 1000 as value size

Cheers @BenjenB

i build dataTable_2 with read range without building it maybe it is why it dont work the way a wanted .Still trying to make it work thank for the advice @Palaniyappan and @Gokul001

1 Like

Fine

Can you elaborate on What issue we are stuck with
@BenjenB

the issue is : i have multiple excel i extract from a website and i try to merge all this excel into one but the format date was changing after the merge MM/dd/yy.

At first i didn’t build the dataTable_2 i use read range to create it

Hi @BenjenB

After merging all the data into a single excel. Read the excel file using Read Range activity.

Store it in DT variable

Use For each row in DataTable Activity

Use assign activity

LHS → CurrentRow(“Column Name”)
RHS → CDate(“Column Name”).Tostring(“dd/MM/yyyy”)

Use Write range activity to write the data in the correct format

Regards
Gokul

@BenjenB

Alternative method

Go to → Manage Package → Install (BalaReva.Excel.activities)

Use Change Cell Type Activity

Regards
Gokul

Datetimes don’t have formats. They’re stored internally as milliseconds since Jan 1 1970. You set the format when you want to output the datetime as a string.

LHS and RHS is what?

Didn’t work

image

destination
image

source
image

it seem all “,” become “.”

mergeTest.xaml (21.5 KB)
BalanceTest.xlsx (9.6 KB)
ORC_IC_70850200_quadrimestre1.xls (28.5 KB)

I try the other write range “Uipath.Excel.Activities.ExcelWriteRange” and not the “Uipath.Excel.Activities.WriteRange” and it work the way I want.
Don’t know the diffirence but it work :ok_hand:

image

The difference is the Workbook activities don’t have to be inside the Excel Application Scope. This makes them faster and simpler since they don’t open the Excel file like EAS does, but it also means they’re more limited in what you can do.

1 Like

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