Date format problem

Hey community, I have a problem I developped a workflow that has as an input a data containing date column dd/mm/yy but after executing the workflow the format date become mm/dd/yy

but I want to keep the same format at beginning HELP

Hi @BlueBird1

At the time of writing the data, you can explicitly convert the mm/dd/yy formatted data to your desired pattern & write it. You can use this expression for the same:


Hope this helps,
Best Regards.

Hi @BlueBird1

  • If you are gettin the data from excel, make sure to set the Preserve Format property enabled.
  • Another solution is to convert the data coming to the format we want
DateTime.ParseExact(yourStringVariable, {"M/d/yy","dd/MM/yy","d/M/yy","MM/dd/yy","MM/dd/yy hh:mm:ss"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("MM/dd/yy")


Actually I didn’t write any dataTable, M just workinng with an excel file and I want to keep the same input format

Hi @BlueBird1 ,

Maybe you could check the below Post :


If you want to keep the data format intact from the time of reading the data, you can use a property called Preserve Format in the Read Range activity.

Selecting this check box keeps the formatting of the cell that you want to read. By default, the check box is cleared.

Hope this helps,
Best Regards.

I will try tthis method and I’ll let u know

Hi @BlueBird1

By Default format of date time in UiPath is MM/dd/yyyy only.
So i you want to Same format after getting your datatable u have to Convert the format with below expression



@supermanPunch I got an error:
Format Cells: Cannot set NumberFormatLocal property of Range class.

@arjunshenoy this is how read range properties look like

should I put in the bloc variable the name of my column?

@Vishnuraj_Pandiyarajan2 I tried what you said and it return this error: Assign: String ‘DATE_TRAITEMENT’ was not recognized as a valid DateTime.

Does the text “DATE_TRAITEMENT” appear anywhere in your column containing the dates? Is it the name of the column header or a variable in your workflow?

Yes it’s the header

Ok so that means the header text is also being fed into the function to parse as date. Can you read the data treating the first row as the header? Just double check that the “A des en-tetes” checkbox is checked.

it’s already checked

Hi @BlueBird1 ,

So here are the required steps:

  1. The input data’s “DATE_TRAITEMENT” column contained text in the format of d/M/yyyy, e.g. 3/5/2023.
  2. To ensure that the output Excel formats the date correctly, create a blank output template with the DATE_TRAITEMENT column cells set to the date format of d/M/yyyy
  3. In the robot workflow, parse the values in the DATE_TRAITEMENT column as dates by using the following code DateTime.ParseExact(CurrentRow("DATE_TRAITEMENT").ToString, "d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture)
  4. When writing out the Excel, copy the output template and give it the name of the output file that you want.
  5. Write the datatable into the output Excel file. The formatting set in Excel will ensure that the date is formatted correctly.


Just before writing it into an Excel sheet, you can transform the data. Use the Invoke Code activity like this:

Keep the Edit Arguments panel like this:

And, paste this code in the Edit Code Panel:

row(“DATE_TRAITEMENT”) = DateTime.ParseExact(row(“DATE_TRAITEMENT”).ToString,"dd/MM/yyyy", Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")
End Sub)

Hope this helps,
Best Regards.

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