# Parse date into a single format

**URL:** <https://forum.uipath.com/t/parse-date-into-a-single-format/495049>\
**Category:** Studio\
**Tags:** date, activities-panel, datatable, question, studio, excel, system, activities\
**Created:** [November 30, 2022, 9:51am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049 "2022-11-30T09:51:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhruvi\_Arumugam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dhruvi_arumugam/32/275480_2.png) [@Dhruvi\_Arumugam](https://forum.uipath.com/u/Dhruvi_Arumugam)\
**Post date:** [November 30, 2022, 9:51am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/1 "2022-11-30T09:51:44Z")

</div>

Hi All,

I have a excel file which has column “Refer Date”, the number of rows in the excel file could be 500k-800k~.

The format in the date column is very inconsistent

examples of date which are present in “Refer Date” column are mentioned below(it consists many formats like M/D/YYYY, MM-D-YYYY, OADate format etc. refer below)

> 3/2/2022, 44595, 28/FEB/2022, 02-3-2022, 01-03-202, 22-02-2022, 14/02/2022, N/A, 2022-01-06-11.59.23.370265, 2022-01-12T17:56:21Z.

I want to convert them into a single consistent format like MM/DD/YYYY

Any help is appreciated.

Thanks!!

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [November 30, 2022, 10:00am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/2 "2022-11-30T10:00:53Z")

</div>

we can make use of the following building blocks:

![grafik](https://global.discourse-cdn.com/uipath/original/4X/a/9/9/a99ed1fbbcfac426bd48973cdade8e95aa4de9f8.png)

Parsing many formats in one go  
ensure the following:  
 ![import_systemglobalization](https://global.discourse-cdn.com/uipath/original/4X/b/e/6/be670ee7025eada99665f26cf639bbb098c83518.png)

arrFormats = {“dd/MMM/yyyy”, “dd-MM-yyyy”, … your other formats}

```auto
DateTime.ParseExact(YourString, arrFormats, cultureinfo.InvariantCulture, DateTimeStyles.None)

```

feel free to adapt the culture info

Finally we can check which case we do have to handle e.g. with regex  
\d+ → OADate  
NA → not parseable  
…

Bringing all together we can parse the date and harmonize the format

---

<div class="post-metadata">

**Author:** ![sangeethaneelavannan1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sangeethaneelavannan1/32/176935_2.png) [@sangeethaneelavannan1](https://forum.uipath.com/u/sangeethaneelavannan1)\
**Post date:** [November 30, 2022, 10:04am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/3 "2022-11-30T10:04:32Z")

</div>

@Dhruvi_Arumugam  
Datetime.ParseExact(Refer Date).tostring(“MM/DD/YYYY”)

---

<div class="post-metadata">

**Author:** ![Gokul001](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gokul001/32/462734_2.png) [@Gokul001](https://forum.uipath.com/u/Gokul001)\
**Post date:** [November 30, 2022, 10:54am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/4 "2022-11-30T10:54:40Z")

</div>

HI @Dhruvi_Arumugam

How about this expression?

```auto
DateTime.ParseExact(YourInput.ToString,{"MM/dd/yyyy","MM/dd/yyyy hh:mm:ss","dd.MM.yyyy"}, System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString(“MM/dd/yyyy”)

```

You can simply add the any number of date formats inside the {“”,“”} and the formats should be separated by comma

The above expression will look into array of string and choose the apt format as per the input string and convert them and return you the output of desired format.

Regards  
Gokul

---

<div class="post-metadata">

**Author:** ![Dhruvi\_Arumugam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dhruvi_arumugam/32/275480_2.png) [@Dhruvi\_Arumugam](https://forum.uipath.com/u/Dhruvi_Arumugam)\
**Post date:** [November 30, 2022, 11:13am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/5 "2022-11-30T11:13:09Z")

</div>

Hi @ppr

Thanks for the reply, but specific to OADate you mentioned we can you use regex, can you please elaborate on that how can we use it in expression, for N/A we can leave it.

Also, how can be use it on all of the data as we have 500k~ + rows.

Thanks!

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [November 30, 2022, 11:14am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/6 "2022-11-30T11:14:50Z")

</div>

can you share some sample data along with the column names?

---

<div class="post-metadata">

**Author:** ![Dhruvi\_Arumugam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dhruvi_arumugam/32/275480_2.png) [@Dhruvi\_Arumugam](https://forum.uipath.com/u/Dhruvi_Arumugam)\
**Post date:** [November 30, 2022, 11:15am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/7 "2022-11-30T11:15:08Z")

</div>

Hi @Gokul001

Thanks for your reply.

How can I handle OADate format? and as I have 500k~ + rows how can i incorporate that change in all.

Thanks.

---

<div class="post-metadata">

**Author:** ![Gokul001](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gokul001/32/462734_2.png) [@Gokul001](https://forum.uipath.com/u/Gokul001)\
**Post date:** [November 30, 2022, 11:20am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/8 "2022-11-30T11:20:19Z")

</div>

HI @Dhruvi_Arumugam

In this case you can try with Format cell activity to get the desired format.

You can try to change the format of the column

1. Excel process scope activity
2. Use excel file activity
3. Format cell activity

 ![image](https://global.discourse-cdn.com/uipath/original/4X/6/1/2/612bc993ec7dcf91e6d6798f1c01d0c4f4c4374d.png)

Check out this XAML file

[FormatCellStudioX.xaml](https://forum.uipath.com/uploads/short-url/gKqgaYqKrAEOAJ2XzB8AaCUzVdY.xaml) (8.5 KB)

**Or**

Try with BalaReva it will applicable only in Window Legacy

[![](https://global.discourse-cdn.com/uipath/original/4X/f/2/9/f29341116c57e2ff68bb3f75e894960fae5ddf17.jpeg "UiPath | How to change the cell or column format in Excel | Guide (datatype)") ](https://www.youtube.com/watch?v=5LYAWUKZZQU)

Check out the thread

> [@\[Part 1\] Modern Activities - Find/Replace Value | Format Cells](https://forum.uipath.com/t/part-1-modern-activities-find-replace-value-format-cells/480017):
>
> Hello Everyone, Hope you are doing good I would like to present this post who are looking for the Modern Activities Very first thing is to Enable the Modern experience (from Classic) Go to → Activities Panel → Click on Filter → Select Show Modern. [image] Let Jump into the Tutorial we are look into some Modern activities Find/Replace Value Format Cells Note : We need to use Excel Process Scope and Use Excel File for all the above activities Excel Process scope Use Excel File …

Regards  
Gokul

---

<div class="post-metadata">

**Author:** ![Dhruvi\_Arumugam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dhruvi_arumugam/32/275480_2.png) [@Dhruvi\_Arumugam](https://forum.uipath.com/u/Dhruvi_Arumugam)\
**Post date:** [December 2, 2022, 6:14am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/9 "2022-12-02T06:14:07Z")

</div>

Hi @Gokul001

Thanks! I will try this.

Thanks

---

<div class="post-metadata">

**Author:** ![Dhruvi\_Arumugam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dhruvi_arumugam/32/275480_2.png) [@Dhruvi\_Arumugam](https://forum.uipath.com/u/Dhruvi_Arumugam)\
**Post date:** [December 2, 2022, 6:28am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/10 "2022-12-02T06:28:53Z")

</div>

Hi @ppr

Apologies for late reply

Please find attached sample  
[Sample.xlsx](https://forum.uipath.com/uploads/short-url/xm1TooCxyR5xNI4imFxu40j9IAw.xlsx) (3.5 MB)

Below are the Columns in the file attached:

**Closing date** ,Team,NCI Value,SA Name,Change Record (CR) #, **Reference Date**

The highlighted columns are the date columns.

Please let me know for any questions.

Thanks

---

<div class="post-metadata">

**Author:** ![Dhruvi\_Arumugam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dhruvi_arumugam/32/275480_2.png) [@Dhruvi\_Arumugam](https://forum.uipath.com/u/Dhruvi_Arumugam)\
**Post date:** [December 5, 2022, 8:59am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/11 "2022-12-05T08:59:40Z")

</div>

@ppr Can you please suggest I provided the sample.

Thanks

---

<div class="post-metadata">

**Author:** ![Dhruvi\_Arumugam](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/dhruvi_arumugam/32/275480_2.png) [@Dhruvi\_Arumugam](https://forum.uipath.com/u/Dhruvi_Arumugam)\
**Post date:** [December 6, 2022, 11:53am UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/12 "2022-12-06T11:53:44Z")

</div>

Hi @ppr

I provided the sample data.

> [@Dhruvi\_Arumugam](#):
>
> Below are the Columns in the file attached:
> 
> **Closing date** ,Team,NCI Value,SA Name,Change Record (CR) #, **Reference Date**
> 
> The highlighted columns are the date columns.
> 
> Please let me know for any questions.
> 
> Thanks

Can you please have a look here and provide some insights.

Thanks

---

<div class="post-metadata">

**Author:** ![Rahul\_Unnikrishnan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rahul_unnikrishnan/32/464046_2.png) [@Rahul\_Unnikrishnan](https://forum.uipath.com/u/Rahul_Unnikrishnan)\
**Post date:** [December 6, 2022, 2:06pm UTC](https://forum.uipath.com/t/parse-date-into-a-single-format/495049/13 "2022-12-06T14:06:30Z")

</div>

Hello @Dhruvi_Arumugam

Here one option is to use the Format cells activity with a loop. But if the format is static for the excel, then better you can create an Excel template with the required formats to the columns and then write the datatable to that excel. It will help to preserve format for all the columns as per our requirement.

Thanks
