How to convert the any date format into a particular format?

I have different date formats and need to convert them to dd-MM-yyyy format. Can anyone guide me?
image

Hi @Kumar_Sahu_Sameer

ā†’ Use Read Range Workbook to read the excel and store the output in a datatable.
ā†’ Use For Each row in Datatable to iterate and use below syntax in Assign activity.

CurrentRow("DOB")= DateTime.ParseExact(CurrentRow("DOB").ToString,{"dd-MM-yyyy","dd MMMM,yyyy","dd-MM yyyy","dd.MM.yyyy"},System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")

ā†’ Use write Range Workbook to write the datatable back to excel.

Make sure to change the date formats and specify the date formats i will give you modified query.

Hope it helps!!
Regards

@Kumar_Sahu_Sameer

First try with Cdate(datevalue)

If that does not work then you need to provide all possible formats but make sure you have only one combination of day-month or month-day and not both

DateTime.ParseExact("DateString",{"dd/MM/yyyy","dd MMMM,yyyy"},System.Globalization.CultureInfo.InvariantCulture)

This convert the string to date and from there to get the date in required format use .ToString("MM/dd/yyyy") whichever is the final format you need

Hope this helps

Cheers

1 Like

@Kumar_Sahu_Sameer
Input:
image

Output:

Sequence14.xaml (8.5 KB)

Hope it helps!!

1 Like

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