Difference Date Error

Hello ,

My process need to calcule the difference between 2 extracted dates , and check if the difference is lower than 3 days , when i test i get the diffrence between the two days is 14 and but it considerate it lower than 3 !!!

i used more than one expression for the diffdates , all gives the same results
here is what am using now

(DateTime.ParseExact(date1, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture)-DateTime.ParseExact(date2, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture)).TotalDays.ToString()

date1 is “31/05/2019”
and date 2 is “17/05/2019”
and the condition is diffdates < “3”

the difference is more than 3 days so the message displayed must be “KO” but it’s "OK "

That’s because you’re comparing them as strings and not as numbers. try cInt(diffdates)<3

1 Like

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