How to Get Date value from Input dialog box

I wanted to get date from input dialog box.

1 Like

Hi, @kla,

Please get that as string from input dialogue box…then write a Regex to validate that string…

That will give you the solution…

Better option would be to use
DateTime.parseExact method

Eg.
DateTime.ParseExact(strUserInput,"dd-MMM-yyyy",System.Globalization.DateTimeFormatInfo.InvariantInfo)

MSDN Reference

[EDIT]
Simply isDate method also works in UiPath
Note that it will return false for 13-01-2017 which is a valid dd-MM-yyyy date
(Most windows machines follow MM-dd-yyyy format and 13 is not a valid month)

Hi @kla,

Kindly check the attached example. It will validate if the user has inserted a correct date and it will only continue once the date is a valid one.

example.xaml (9.5 KB)

5 Likes

I would restrain myself from doing those generalizations - “most” is dependant on the reader and EU still exists ;). Besides, if you don’t specify a culture or formatting, UiPath uses invariant (basically US formats).
For parsing dates, decimals and other culture-sensitive formats always specify the format or culture that’s relevant. In these cases explicit = better in 99,9% of the time, especially if you have multinational teams. Debugging this later is a pain if it works for some and fails for others.

1 Like

need to grow my perspective…:wink:
I’m currently on India format :slight_smile:

1 Like

It works fine:) Thanks