Daysbetween functionality

I have the following expression to calculate the amount of days between the current date and someones birthday: daysBetween(trimToDays([%CurrentDateTime%]), addYears($IteratorEmployee/DateOfBirth, floor(daysBetween($IteratorEmployee/DateOfBirth, trimToDays([%CurrentDateTime%])):365))) I enterd the following values to the variables: [%CurrentDateTime%] = 10-03-2010 and $IteratorEmployee/DateOfBirth = 13-03-1989 I wrote the whole expression step by step while calculating parts of the expression: daysbetween(10-03-2010, addyears(13-03-1989,floor(daysbewteen(13-03-1989, 10-03-2010):365)) daysbetween(10-03-2010, addyears(13-03-1989,floor(7666:365)) daysbetween(10-03-2010, addyears(13-03-1989, 21)) daysbetween(10-03-2010, 13-03-2010) The result is 3 days. This is correct. But the follwing calculation isn't correct: New variables: [%CurrentDateTime%] = 10-03-2010 and $IteratorEmployee/DateOfBirth = 07-03-1989 daysbetween(10-03-2010, addyears(13-03-1989,floor(daysbewteen(07-03-1989, 10-03-2010):365)) daysbetween(10-03-2010, addyears(07-03-1989,floor(7672:365)) daysbetween(10-03-2010, addyears(07-03-1989, 21)) daysbetween(10-03-2010, 07-03-2010) The result is 3, but it should be -3. Does anyone think the same as me, should the result be -3. Or is it logical that the result is 3?
2 answers

The daysBetween function is defined as returning the absolute number of days (including fractions) between the two given DateTime values. This means that the return value is always a positive number and does not depend on parameter order.

You could always use the greater than operator (>) to check whether date1 is greater than date2 and use the appropriate value accordingly:

if $date1 > $date2 then
    -daysBetween($date1, $date2)
    daysBetween($date1, $date2)

I don't think it's very logical

I already solved this issue before posting this topic. I only wanted to know the opinions of others about this.

But thanks for the explanation.