Hi,
I am trying to convert a string into desired format. e.g. If string/datetime is 14-02-2022 06:32:00 then output should be Feb22. For doing the same, I have tried the following methods:
Datetime.ParseExact(dateCol.ToString,“dd-MM-yyyy hh:mm:ss”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MMMY”)
Convert.ToDateTime(dateCol.ToString.Trim).ToString(“MMMyy”)
Datetime.Parse(dateCol.ToString).ToString(“MMMY”)
Also, I have tried multiple date formats, just to check but I am finding the below error again and again.
Error: Update Month Column: String was not recognized as a valid DateTime.
Request the readers to let me know if there is any other method for doing the same. or how to debug the same.
Any help is appreciated.
ppr
(Peter Preuss)
March 24, 2022, 6:14pm
2
Datetime.ParseExact(“14-02-2022 13:32:00”,“dd-MM-yyyy HH:mm:ss”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MMMY”)
as 13:32:00 occurs we would parse with HH for the hours
ppr
(Peter Preuss)
March 24, 2022, 6:17pm
3
this will help:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum
And also have a look here:
@Dr_Raza_Abidi_PhD
in case of hugh data we would recommend to do a mass analysis on non parseable dates and get found out which values are blocking.
set a breakpoint on a relevant location
debug and get paused
open immediate panel
run following statement
dtData.AsEnumerable.Where(Function (d) Not DateTime.TryParseExact(d("ETB/NTB").toString, YOURFORMATSTRING, CultureInfo.InvariantCulture, DateTimeStyles.None, Nothing)).toList
have some help from here:
Understanding the 6 Debugging Panels …
adding to Peter’s suggestions:
HH -means 24 hours format
hh -means 12 hours format
when you pass 13:08 to “hh:mm” it fails as 13 is not valid in 12 hours formatting
So using HH will work
system
(system)
Closed
April 6, 2022, 11:27am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.