Convert multiple date format into specific format

Hi,

I have an column in which multiple date format has present.
so I want to convert all format into specific format i.e. MM/dd/yyyy

Sample Data:

20/02/24
02/30/2024
13-08-2024
13/08/2024 so on…

Hi @itbuddy1

Use the below code in Invoke Code:

dt.AsEnumerable().ToList().ForEach(Sub(row) row("DateColumn") = DateTime.ParseExact(row("DateColumn").ToString().Trim(), {"dd/MM/yy", "dd/MM/yyyy", "MM/dd/yyyy", "dd-MM-yyyy"}, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None).ToString("MM/dd/yyyy"))

Pass dt as In/Out as DataTable.

Hope it helps!!

@itbuddy1

check this thread as reference

hi, thanks for the solution but this will convert only some data.
for your reference I am provide more sample data.

can u provide me the solution accordingly

28-09-2024
12-09-2024
23-09-2024
26-09-2024
26-09-2024
25-09-2024
11-09-2024
26-09-2024
25-09-2024
02-09-2024
27-09-2024
10-09-2024
26-09-2024
27-09-2024
01-09-2024
27-09-2024
07-09-2024
27-09-2024
28-09-2024
28-09-2024
28-09-2024
28-09-2024

Hi @itbuddy1

Can you share the data through Excel file. I will help you with flow.

Regards

I already share the data in above chat these are in date format in an excel

Plz help me because this process is running in production

Hi @itbuddy1

Use Format Cells activity

Regards,

@itbuddy1

Regards,

Hi,

I tried above solution that is work but only work in which cell is in date type not in custom type
actually in this file some date type is date or some is custom type.

I have attached the actual data which I have received from user
Sample.xlsx (9.3 KB)

Hi @itbuddy1

Can you try below xaml

Sequence15.xaml (14.0 KB)

Output:

Regards,

Hi,

I am not able to open this XAML. This is showing invalid document.

@itbuddy1

dt.AsEnumerable().ToList().ForEach(Sub(row) row("Proposed End Date") = DateTime.ParseExact(row("Proposed End Date").ToString().Trim(), {"M/dd/yyyy", "dd-MM-yyyy"}, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None).ToString("MM/dd/yyyy"))

Note: Enable Preserve Format Option in Read Range Workbook activity

Regards,