Comparing three datetime variables

Hello everyone,

I am trying to compare three datetime variables(actually these are arguments if it matters).

Variable1 = 01/05/2019 00:00:00
Variable2 = 01/10/2019 00:00:00
Variable3 = 01/31/2019 00:00:00

I wrote if statement below

If Variable1 <= Variable2 AndAlso Variable2 <= Variable3

Then message “successful”
Else message “failed”

From my understanding, “successful” should come up but I got “failed”.

I don’t know if using ‘<=‘ is the best way to compare datetime variables.

Could you help me to resolve this?

@9e389f79ff1549b677ac

I have tried the same expression, its working as you expected.

Check this xaml .Sample.xaml (5.7 KB)

You can use

datediff(DateInterval.day, Variable2, Variable1)>0 and datediff(DateInterval.day, Variable3, Variable2)>0

Convert the variables into “datetime” then use “Compare Date” Activity.

Thank you very much fro your comment.
In the end I found that I twisted the values when I created the arguments.

1 Like