Hi, I’m having trouble with the IsBetweenDates function when writing an expression. My understanding is I should be able to provide it with two dates (inc. time) and if the current time is between those two, it will return true, else false. However, if I enter the following expression, it is evaluating to true:
Now this should not be true, as the current time cannot be between 8 hours ago and 10 hours ago! If I change the addHours to addDays, I get false. This leads me to think perhaps the function is limited to just the date, and doesn’t look at the time?
These simple comparisons get a bit more complicated when you are trying to compare between two calendar dates as there’s some manipulations needed. Without getting into all the details of it, you have to do a bunch of manipulations like resetting the year component, shifting the time on the ‘end’ date to the time at the end of the day, shifting years back and forth if it’s a cross-year comparison, etc.
So we built the isBetweenDates() as a bit of ‘syntactic sugar’ to make it easier to just compare those calendar dates directly without the overhead of having to rebuild all that logic.
For points in time, you can just use the comparison operators directly as shown above, so the special method isn’t needed.