Hi,
I have two variable both are string variable
str1 = “08/20/2024”
str2 = “08/20/2024”
if i use compare option it is going else block like both are not equal.
How to fix this , as per string both are equal but it’s going to else block.
Thanks,
Rama
ppr
(Peter Preuss)
August 15, 2024, 1:04pm
2
you are doing a sting comapare and on string is not having the 0 =8 vs 8 so it is not equal
Jon_Smith
(Jon Smith)
August 15, 2024, 1:05pm
3
The strings are clearly not equal. One has a zero, the other doesn’t.
If you convert them to DateTime instead of string, you can then check if they are equal.
Also doing .ToString on a string doesn’t do anything, its already a string.
1 Like
lrtetala
(Lakshman Reddy)
August 15, 2024, 1:05pm
4
Hi @rama_krishna_Rao
Try this
If DateTime.ParseExact(str1, "MM/d/yyyy", System.Globalization.CultureInfo.InvariantCulture) = DateTime.ParseExact(str2, "M/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) Then
' Dates are equal
Else
' Dates are not equal
End If
Regards,
singh_sumit
(Sumit Singh Tariyal)
August 15, 2024, 3:09pm
6
Hie @rama_krishna_Rao look your 2 variable value your 2 value are both different thats why your if logic value is not equal
Cheers Happy Automation…
1 Like
got it what i did mistake Thanks so much Peter
system
(system)
Closed
August 18, 2024, 4:47pm
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.