If I run the following formula:
DateTimeAdd(ToDate("2022-12-31"), 0, "years") <= ToDate("2022-12-31")
I would expect to get TRUE (since the dates on both sides should be the same). However, running this (in version 2022.1.1.25127), I get FALSE.
What seems to be happening is that DateTimeAdd outputs a DateTime rather than a Date and if x is Date stored as a Date and y is the identical date but stored as a DateTime then y<x.
If I wrap the DateTimeAdd in a ToDate:
ToDate(DateTimeAdd(ToDate("2022-12-31"), 0, "years")) <= ToDate("2022-12-31")
Then I get TRUE as I would expect.
Not sure whether this is enough to classify as a bug (given the easy fix with wrapping in ToDate) but certainly wasn't the behaviour I was expecting and caused me issues when I was trying to check if Date + some number of years is after some other fixed date (as the equality case didn't behave as expected).
Hi @SamBealing
I believe that the problem here is that you are comparing a datetime (that comes from the DateTimeAdd function) with a date (that comes from the ToDate function). If you compare them both as dates or datetimes, you will get the expected result.
you can use a datetime diff to simplify in a single formula.