How to Get Date value from Input dialog box


#1

I wanted to get date from input dialog box.


#2

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…


#3

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)


#4

Hi @kla,

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

example.xaml (9.5 KB)


#5

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.


#6

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


#7

It works fine:) Thanks