Date coversion problem

Hi Team,.

I am getting an error - String was not recognized as a valid date time

Extracting date from an application its format is
Sep 15, 2022 8:25 AM - Storing in a String variable(Test1)

While conversion i am getting this error
Test2(Datetime variable) = DateTime.ParseExact(Test1,“MMM dd, yyyy hh:mm tt”, System.Globalization.CultureInfo.InvariantCulture)

System.Datetime.ParseExact(DateTimeStr,“MM/dd/yyyy HH:mm:tt”,New system.Globalization.CultureInfo(“en-US”)).ToString(“MM-dd-yyyy HH-mm”)

Try with this and simple store in string variable


Can you try as the following? (Modified “hh” to “h”)

Test2(Datetime variable) = DateTime.ParseExact(Test1,"MMM dd, yyyy h:mm tt", System.Globalization.CultureInfo.InvariantCulture)


yellow represent you are getting and red represent you want to convert

Hi @Robotics

How about this expression?

DateTime.ParseExact("Sep 15, 2022 8:25 AM","MMM dd, yyyy h:mm tt",System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy") "09/15/2022"



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