I’m trying to compare two date, both I’m capturing from application and storing in variable with variable type = string
Just assume variable A and B.
A=05/04/2020
B=05/04/2020
After that I’m comparing with if condition.
Condition is A=B.
It should to go then part as both A and B are having same values but it’s going to else part.
Is anything Am missing here?
Yoichi
(Yoichi)
2
Hi,
I suppose there is a possibility they contains some white spaces.
Can you try the following?
Set breakpoint at IF activity and check content of A and B if there are same with debug mode.
or
Try A.Trim() = B.Trim() as condition of IF activity.
Regards,
1 Like
GBK
(GBK)
3
@vaibhav2.chavan - pls try below
A=05/04/2020
B=05/04/2020
A.Trim.ToString.Equals(B.Trim.ToString)
True
@Yoichi - It worked. Thank you for your help.
What is the difference if i use Try A.Trim() = B.Trim()
GBK
(GBK)
5
Technically both .Equals & = works same…
but for a best practices - it always recommend to use .Equals
or
you can go with much version of string comparison
Strings.Equals(Trim(A),Trim(B))
1 Like