0
votes

I have tried everything that I can think of to get the right date format. Can anybody help with this RPA-problem in UiPath. I have used the 'get text' activity to get the folder date and after that tried to use the

Datetime.ParseExact(Str variable,"dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).

It gives me the error:

Assign: String was not recognized as a valid DateTime.

Your help is much appreciated.

edit: I have now sought help from a friend who figured it out. The error was in the string, which could not be seen, because there was an invisible character in the string that I extracted through 'get text' activity. The solution is in 2 steps:

  1. assign another variable to the exact same date and use an if statement to find out if these two strings are equal and you will find out that they are not.

  2. Now use a regex to capture only digits and slash/hyphen which will get rid of the invisible character.

2
What does the String that you're trying to parse look like? - jmcilhinney
The date time string looks like this: 22/01/2020. - Salam Hussain Katawazi
The solution is in the main text. - Salam Hussain Katawazi

2 Answers

1
votes

Try to use "dd_MM_yyyy" instead of "dd/MM/yyyy".

0
votes

The reason is because UiPath/VB.Net has a habit of using US date formatting even though you're using Culture Info...It's a real pain

Try this:

pDateString = "21/02/2020"
Assign a Date type variable = Date.ParseExact(pDateString,"dd/MM/yyyy",nothing)

Here we're telling the parser to use English format date...The Date type returned will be in US format but you can simply convert back to uk IF needed by using something like:

pDateString("dd/MM/yyyy")