I am running into the following error message:
String was not recognized as a valid DateTime.
Here is the full code below:
DateTime.ParseExact(startDate, “MM/dd/yyyy”, System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)
Any thoughts on what the issue might be?
Thanks!
@I_Am_A_RPA_Noob
Its happening due to possible case.
DateTime.ParseExact(startDate, “MM/dd/yyyy”, System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)
This expression returns datetime variable and you need a string.
So please try this one.
DateTime.ParseExact(startDate, “MM/dd/yyyy”, System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat).ToString
Thanks for your input. I tried out your suggestion but I ended up getting the following error message.
Gokul001
(Gokul Balaji)
October 10, 2022, 3:29pm
5
Hi @I_Am_A_RPA_Noob
Check out this expression
DateTime.ParseExact("startDate",{"MMM dd, yyyy","MMM d, yyyy","MMM d, yyyy hh:mm tt","MMM dd, yyyy hh:mmtt"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("MMM dd, yyyy")
Regards
Gokul
@I_Am_A_RPA_Noob
DateTime.ParseExact(startDate, “MM/dd/yyyy”, System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)
Please check your input variable. There will be some issues with it.
Regards
Sreejith S S