My variable ‘scrapedDate’ is a string and it is ‘2nd January 2020’
My datetime variable is ‘newDate’ and its assigned to ‘Date.parseexact(scrapedDate,“dd/MMMM/yy”,system.globalization.cultureinfo.invariantculture)’.
It’s saying the string isn’t a valid date time. Whenever I used ‘02012020’ the conversion works ok so I know the problem is with the string.
Hi
welcome to uipath community
kindly try with this expresion
if the input is in a variable named str_input
then
use a assign activity like this str_input = System.Text.RegularExpressions.Regex.Match(Split(str_input.ToString," “).(0).ToString.Trim,”(\d).“).tostring.PadLeft(2,cchar(“0”))+” “+Split(str_input.ToString,” “).(1).ToString.Trim+” “+Split(str_input.ToString,” ").(2).ToString.Trim
so now we will be ggetting as str_input = “02 January 2020”
now use a assign activity like this str_output = Datetime.ParseExact(str_input.tostring,“dd MMMM yyyy”,system.globalization.cultureinfo.invariantculture).tostring(“dd/MM/yyyy”)
or
to use as a datetime variable date_output = Datetime.ParseExact(str_input.tostring,“dd MMMM yyyy”,system.globalization.cultureinfo.invariantculture)
where date_output is a variable of type system.datetime