# Date format problem

**URL:** <https://forum.uipath.com/t/date-format-problem/543649>\
**Category:** Studio\
**Tags:** studio, excel, system, activities\
**Created:** [May 10, 2023, 7:32pm UTC](https://forum.uipath.com/t/date-format-problem/543649 "2023-05-10T19:32:55Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlueBird1](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@BlueBird1](https://forum.uipath.com/u/BlueBird1)\
**Post date:** [May 10, 2023, 7:32pm UTC](https://forum.uipath.com/t/date-format-problem/543649/1 "2023-05-10T19:32:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![arjunshenoy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/arjunshenoy/32/404588_2.png) [@arjunshenoy](https://forum.uipath.com/u/arjunshenoy)\
**Post date:** [May 10, 2023, 7:38pm UTC](https://forum.uipath.com/t/date-format-problem/543649/3 "2023-05-10T19:38:36Z")

</div>

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:

`yourDateValue.ToString(“dd/MM/yy”)`

Hope this helps,  
Best Regards.

---

<div class="post-metadata">

**Author:** ![fernando\_zuluaga](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/fernando_zuluaga/32/462699_2.png) [@fernando\_zuluaga](https://forum.uipath.com/u/fernando_zuluaga)\
**Post date:** [May 10, 2023, 7:39pm UTC](https://forum.uipath.com/t/date-format-problem/543649/4 "2023-05-10T19:39:32Z")

</div>

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

```auto
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")

```

Regards!

---

<div class="post-metadata">

**Author:** ![BlueBird1](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@BlueBird1](https://forum.uipath.com/u/BlueBird1)\
**Post date:** [May 10, 2023, 7:40pm UTC](https://forum.uipath.com/t/date-format-problem/543649/5 "2023-05-10T19:40:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [May 10, 2023, 7:41pm UTC](https://forum.uipath.com/t/date-format-problem/543649/6 "2023-05-10T19:41:50Z")

</div>

Hi @BlueBird1 ,

Maybe you could check the below Post :

> [@DateTime.ParseExact the whole Column without looping](https://forum.uipath.com/t/datetime-parseexact-the-whole-column-without-looping/523225/11):
>
> Hi @arthurang , If the Target Goal for you is to represent the dates in Excel Sheet Column in MM/dd/yyyy format, maybe you could use the Format Cells Activity if you have the latest versions in place. You would require to know which column the Date column is present (A or B or C, in my case it is J), then we can use the Range as J:J. If we do not know the position of the column in the Excel sheet too, we can dynamically be able to find it as well. Input : [image] Output: [image] …

---

<div class="post-metadata">

**Author:** ![arjunshenoy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/arjunshenoy/32/404588_2.png) [@arjunshenoy](https://forum.uipath.com/u/arjunshenoy)\
**Post date:** [May 10, 2023, 7:44pm UTC](https://forum.uipath.com/t/date-format-problem/543649/7 "2023-05-10T19:44:31Z")

</div>

@BlueBird1

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.

---

<div class="post-metadata">

**Author:** ![BlueBird1](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@BlueBird1](https://forum.uipath.com/u/BlueBird1)\
**Post date:** [May 10, 2023, 7:50pm UTC](https://forum.uipath.com/t/date-format-problem/543649/8 "2023-05-10T19:50:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vishnuraj\_Pandiyarajan2](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vishnuraj_pandiyarajan2/32/357360_2.png) [@Vishnuraj\_Pandiyarajan2](https://forum.uipath.com/u/Vishnuraj_Pandiyarajan2)\
**Post date:** [May 10, 2023, 7:56pm UTC](https://forum.uipath.com/t/date-format-problem/543649/9 "2023-05-10T19:56:57Z")

</div>

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

`DateTime.ParseExact(YourVariable,"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")`

Thanks  
VP

---

<div class="post-metadata">

**Author:** ![BlueBird1](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@BlueBird1](https://forum.uipath.com/u/BlueBird1)\
**Post date:** [May 10, 2023, 8:05pm UTC](https://forum.uipath.com/t/date-format-problem/543649/10 "2023-05-10T20:05:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BlueBird1](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@BlueBird1](https://forum.uipath.com/u/BlueBird1)\
**Post date:** [May 10, 2023, 8:09pm UTC](https://forum.uipath.com/t/date-format-problem/543649/11 "2023-05-10T20:09:54Z")

</div>

@arjunshenoy this is how read range properties look like  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/d/0/8/d08c55791a9c911994068ddf155cf59b1789d1ec.png)

---

<div class="post-metadata">

**Author:** ![BlueBird1](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@BlueBird1](https://forum.uipath.com/u/BlueBird1)\
**Post date:** [May 10, 2023, 8:17pm UTC](https://forum.uipath.com/t/date-format-problem/543649/12 "2023-05-10T20:17:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BlueBird1](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@BlueBird1](https://forum.uipath.com/u/BlueBird1)\
**Post date:** [May 10, 2023, 8:27pm UTC](https://forum.uipath.com/t/date-format-problem/543649/13 "2023-05-10T20:27:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yikwen.goo](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yikwen.goo/32/188704_2.png) [@yikwen.goo](https://forum.uipath.com/u/yikwen.goo)\
**Post date:** [May 11, 2023, 3:54am UTC](https://forum.uipath.com/t/date-format-problem/543649/14 "2023-05-11T03:54:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BlueBird1](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@BlueBird1](https://forum.uipath.com/u/BlueBird1)\
**Post date:** [May 11, 2023, 7:34am UTC](https://forum.uipath.com/t/date-format-problem/543649/16 "2023-05-11T07:34:16Z")

</div>

Yes it’s the header

---

<div class="post-metadata">

**Author:** ![yikwen.goo](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yikwen.goo/32/188704_2.png) [@yikwen.goo](https://forum.uipath.com/u/yikwen.goo)\
**Post date:** [May 11, 2023, 7:49am UTC](https://forum.uipath.com/t/date-format-problem/543649/17 "2023-05-11T07:49:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BlueBird1](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@BlueBird1](https://forum.uipath.com/u/BlueBird1)\
**Post date:** [May 11, 2023, 8:39am UTC](https://forum.uipath.com/t/date-format-problem/543649/18 "2023-05-11T08:39:48Z")

</div>

it’s already checked

---

<div class="post-metadata">

**Author:** ![yikwen.goo](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yikwen.goo/32/188704_2.png) [@yikwen.goo](https://forum.uipath.com/u/yikwen.goo)\
**Post date:** [May 11, 2023, 8:51am UTC](https://forum.uipath.com/t/date-format-problem/543649/19 "2023-05-11T08:51:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![arjunshenoy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/arjunshenoy/32/404588_2.png) [@arjunshenoy](https://forum.uipath.com/u/arjunshenoy)\
**Post date:** [May 11, 2023, 9:45am UTC](https://forum.uipath.com/t/date-format-problem/543649/20 "2023-05-11T09:45:10Z")

</div>

@BlueBird1

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

 ![image](https://global.discourse-cdn.com/uipath/original/4X/1/0/f/10f6e289c037a0ea40b85915f117b05b383e2306.png)

Keep the Edit Arguments panel like this:

 ![image](https://global.discourse-cdn.com/uipath/original/4X/c/2/2/c225b9bb829e32363f628011822930cda8150990.png)

And, paste this code in the Edit Code Panel:

```auto
io_dt.AsEnumerable.ToList.ForEach(Sub(row)
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.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [May 14, 2023, 9:45am UTC](https://forum.uipath.com/t/date-format-problem/543649/21 "2023-05-14T09:45:16Z")

</div>

Closed on May 14, 2023, 9:45am UTC

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