How to convert the multiple date formats into required date format?

I want to convert the unknown date formats into the required date format(dd-MM-yyyy).

For example,
The input may be,
Jun-12-2020 (or) 13/08/2020 11:23:00 (or) 05-01-2020.

But I want the output as follows
12-06-2020
13-08-2020
01-05-2020

Any suggestions for the above issue?

Thanks
Praveen

This should help you out

1 Like

Hi @PRAVEENTHUYAMANI

Have you tried using below format :-

CDate(varInWhichDateIsStored).ToString("dd-MM-yyyy") 

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

I would recommend passing in an array to the datetime.parseexact() formula that @AkshaySandhu pointed out.

If you think there might be additional formats in the future, you can put the string array in your config file for easy alteration without needing to re-publish your code

1 Like

I’ve tried it, it works for the first and the last format dates indicated by @PRAVEENTHUYAMANI but not for the format “13/08/2020 11:23:00”.