Robotics
(Bala)
October 6, 2022, 2:55pm
1
Hi Team,
I am extracting a date in string format say Jan 1, 2022
Conversion should work even if the date is Jan 10, 2022
I want to convert to Date time for which ever the date comes 1 single digit or 10 two digits
Current Code
DateTime.ParseExact(Test,“MMM d, yyyy hh:mm tt”, System.Globalization.CultureInfo.InvariantCulture)
Gokul001
(Gokul Balaji)
October 6, 2022, 2:57pm
2
Hi @Robotics
How about this expression?
DateTime.ParseExact("Jan 01, 2022",{"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
brunabruno
(Bruna Cavalcanti Bruno)
October 6, 2022, 3:08pm
3
Hello Robotics,
This way you are doing it works! Delete “hh:mm tt” of your code…
DateTime.ParseExact(Test,“MMM d, yyyy”, System.Globalization.CultureInfo.InvariantCulture)
Convert.xaml (6.7 KB)
Robotics
(Bala)
October 6, 2022, 3:29pm
4
Gokul001:
InvariantCulture
Thanks for your time Gokul.
Date i am extracting is Oct 6, 2022 2:55PM
Placed your code in assign storing the result in a Datetime variable. Still the same error
String was not recognized as valid datetime
Gokul001
(Gokul Balaji)
October 6, 2022, 3:32pm
5
HI @Robotics
Try with this
DateTime.ParseExact("Jan 01, 2022",{"MMM dd, yyyy","MMM d, yyyy","MMM d, yyyy hh:mmtt","MMM dd, yyyy hh:mmtt"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("MMM dd, yyyy")
Hi @Robotics try this one:
strDate=“Oct 6, 2022 2:55PM”
DateTime.ParseExact(strDate,“MMM d, yyyy h:mmtt”, CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)
Robotics
(Bala)
October 7, 2022, 7:48am
7
Not working storing result in datetime variable
2:55 PM changed the code to h:mm tt",
Still the same error
Gokul001
(Gokul Balaji)
October 7, 2022, 7:49am
8
Can you share the Input string?
have you try with below express @Robotics
Gokul001:
Try with this
DateTime.ParseExact("Jan 01, 2022",{"MMM dd, yyyy","MMM d, yyyy","MMM d, yyyy hh:mmtt","MMM dd, yyyy hh:mmtt"},System.Glo
DateTime.ParseExact("Jan 01, 2022",{"MMM dd, yyyy","MMM d, yyyy","MMM d, yyyy hh:mm tt","MMM d, yyyy hh:mmtt","MMM dd, yyyy hh:mm tt","MMM dd, yyyy hh:mmtt"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("MMM dd, yyyy")
Regards
Gokul
@Robotics okay check this code.
Sequence1.xaml (6.3 KB)