If Condition: String was not recognized as a valid DateTime

Hi, I am having an issue with my If Activity condition. Its having a “String was not recognized as a valid DateTime” error. I’m not sure what went wrong in the condition I set.

Welcome to the forum

Feel free to share with more value details / samples and explore within debugging:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

We do feel that Left(…, 16) can return 16 chars, but the format dd/MMM/yyyy is only 11 chars long


I tried adding a message box to get the output of the item.Headers(“Date”). Here’s the result.


date from message box is not in the format of dd/MMM/yyyy

So the exception is valid.

Kindly note:

First 2 samples are demonstating Conversion Options
Third sample is about showing the -0400 ignoration

We can see the baselined time part. On midnight borders it can result to a different date. So the cutoff can maybe risky

When the handling of multiple formats is needed we can do:

taken from:


Try to mention like this

Datetime.ParaeExact(item.Headers(“Date”).ToString.Trim, “ddd, dd MMM yyyy HH:mm:ss zzz”, System.Globalisation.CultureInfo.InvariantCulture).ToShortDateString

For more info

Hope this helps
Cheers @Zorina25

This is the variable MailMessage its getting. I think I’m doing the configurations wrong.

refering to your image


But with the hint of the timezone US/Eastern maybe also a baselining is recommended