Message Box: String was not recognized as a valid

I have date variable

x = “Tue, 8 Dec 2020 09:59:46 -0600”

so when I use

Datetime.ParseExact(x, “ddd, dd MMM yyyy HH:mm:ss zzz”, nothing).ToString(“yyyyMMdd_HHmmss”)

But it fails when date is in single digit as error message shown in subject line.
Date can be both in single and double digit. So how this can be handled robustly

Thanks in advance


Check as below

Check below for your reference
Convert Date & Time Format Tutorial

Hope this helps you


1 Like

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