How to convert date in the format "Sat Dec 31" to "MM/dd/yyyy"

How to convert date in the format “Sat Dec 31” to “MM/dd/yyyy”

@Gavara_Dileep_Kumar
Welcome to UiPath community Datetime.parsexact(“sat Dec 2021”,“ddd MMM yyyy”).tostring(“MM/dd/yyyy”)

@Gavara_Dileep_Kumar

You should be having year as well to be able to get it properly

So here is how you convert it

Datetime.ParseExact(inputdate,"ddd MMM dd",system.globalization.InvariantCulture).ToString("MM/dd/yyyy")

Cheers

it’s showing an error string was not recognized as a valid datetime
Date
can you please guide me.

@Gavara_Dileep_Kumar

When you read this in UiPath…the format might be changing…can you check after reading …using a log mesaage on how the value is coming

Cheers

Hi @Gavara_Dileep_Kumar

As @Anil_G said, you need to have the Year value for this.
You can use some string manipulation before you send the format to be converted.

You have your date as Sat Dec 31, I’m assuming the year for the date is 2022. You can add/concat 2022 after your date and use this:

Datetime.ParseExact(“Sat Dec 31 2022”,“ddd MMM dd yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

1 Like

@Gavara_Dileep_Kumar

Please have a look at this workflow. I hope this helps you.
DateFormat.zip (9.9 KB)

1 Like

Can you share the sample excel file? @Gavara_Dileep_Kumar

Hi @Gavara_Dileep_Kumar

DateTime.ParseExact(“input”, “format type”, CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

Try this code

Regards,
Kaviyarasu N