Another slightly different way to do it (that’s a simpler idea, but rather harder to construct in the expression editor) is:
- Current Date Time (set hours to 0 set minutes to zero set seconds to 0) < User’s Days Active (sorted by date descending):first item
This will be true if the start of today is before the most recent Days Active (meaning that we already recorded a Days Active for today… and so should not create one)
- Current Date Time (set hours to 0 set minutes to zero set seconds to 0) > User’s Days Active (sorted by date descending):first item
This will be true if the start of today is after the most recent Days Active (meaning that we have not yet recorded a Days Active for today… and so we can create one)
But personally, I prefer comparing the dates text-wise as I described before. The expressions above are carpal-tunnel inducing to create! (Also, there’s just the annoyance of having to do the Current Date Time modification first as you cannot construct that on the right hand side of the comparison.)
some_moment.isSame(some_other_moment, "day"), which returns true if the moments occur on the same day.)
EDIT: As a further aside, believe it or not, formatting the two dates as strings (text) and comparing for equality in “string space” is more performant (faster) than doing it datewise, at least the last time I checked.
And there are, of course, many other ways to make this same determination. Like, we could construct a date range that goes from the start of today to the start of tomorrow and ask if that range contains both the most recent Day Active and Current Date/Time. But that would be silly when the first option is so easy and fast.