Validate dates

Hello everyone! I have a doubt. I want to compare two dates to know if the final date is greater than the initial date, for example:

Correct case:
start date: 09/16/2022
end date: 09/20/2022

Wrong case:
start date: 09/16/2022
end date: 09/13/2022

In advance, thank you so much for your help

Forgot to say. I am using a form to get the dates

Hi @camilacalderon,

You can compare your datetime variables with conditions. Like this:

boolControl = EndDate > StartDate

If this condition(boolControl) is true, your validation is true.

If false, you will change your dates.


1 Like

Thanks for your reply @omer.ozturk. But if I want to do the validation in the form, so that the person entering the date knows that the end date has to be greater than the start date, where should I do it? I am using UiPath.form.Activities

Hi @camilacalderon ,

Maybe you could try using the Logic Property of the Forms for comparing the Dates and Popping up the Error Message :

Form Design :

Here, the Text Field shown is the error Message and is Hidden and Disabled.

On the Text Field element, we create a Logic as shown below :

JavaScript used :

  result = true;
  result = false;

date1 & date2 are the field keys of Date 1 and Date 2 Date pickers.

Then, Save Action, Save Logic and Try out the Form.

Let us know if this doesn’t work out.

1 Like

Thanks for your help!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.