Hi its me again I was used to use the pick a dete option available in form activity, since I cant use the forms anymore I was wondering how to have the imput of a date, the problem is that in my automatation in some cases the date must be in format “yyyy/MM/dd” and in others “dd/MM/yyyy” and I dont see good add to inputs asking the date in different format thank you
If you working with input dialog you can ask user to write date in one specific format and change it in your workflow. Additionally after input you can make validation so the if statement that check if string is in correct format. If not, prompt user with message box that the format is incorrect. And all of that could be stored in do while.
This loop will continuously ask user to type correct date format if validation will fail.
Hi @Juandix
Another approach once the user input the date is convert it later in UiPath to the format you want to work using this function
DateTime.ParseExact(strInput,{"M/d/yyyy","dd/MM/yyyy","d/M/yyyy","MM/dd/yyyy","MM/dd/yyyy hh:mm:ss"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("dd/MM/yyyy")
You can get the data in specific format and then convert it to required format in your process instead of requesting in multiple formats
Cdate("Inputdate").ToString("yyyy/MM/dd")
like this you can convert to any format you need
If say input format is fixed always then
Datetime.parseexqct("Inputstring","MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy/MM/dd")
Either of these can be used to convert date from one format to another
Cheers
Hi @Juandix,
- Store the user input in a variable (let’s call it
inputDate
). - Use the
DateTime.ParseExact
method to convert theinputDate
string to aDateTime
object in the desired format:
vb.netCopy code
Dim outputDate As DateTime = DateTime.ParseExact(inputDate, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
//Convert the output date to the desired format
Dim outputDateString As String = outputDate.ToString("yyyy/MM/dd")
In this example, the DateTime.ParseExact
method converts the inputDate
string to a DateTime
object using the format “dd/MM/yyyy”. The resulting DateTime
object is then converted to a string in the format “yyyy/MM/dd” using the ToString
method.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.