Conversion from String to Date

I successfully extracted the date from the name of a report file which is 190902(as a string). I have difficulty converting the date to 07-SEP as required in my project. I keep getting the error string(190902) is not in a valid date format

Datetime.parseexact(stringvariable,ddMMyy,system.globalisation.cultureinfo.invariantculture).tostring(“dd-MMMM-yyyy”)

Please use this code.

Different date formats available here. Check it out.

Hi

Welcome to uipath community

Hope this expression would help you resolve this
If your input is
str_input = “190902”

str_output = DateTime.FromOADate(Convert.ToDouble(str_input.ToString)).ToString(“dd-MMM”)

Kindly try this and let know for any queries or clarification
Cheers @realistic24

Thanks guys. @kadiravan_kalidoss. I got the prompt that globalisation is not a member of string.
@Palaniyappan. It returned 01-Sep instead of 02-SEP. How do I twerk it to return 02-SEP

DateTime.ParseExact(“190902”, “ddMMy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM”)

DateTime.ParseExact( stringvariableDate, “ddMMy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM”)

Tested output: 19-Sep

@kadiravan_kalidoss. Thanks it’s working.
@Palaniyappan. Thanks

1 Like