Find the difference within a dateRange in days

{{(moment(dateRange.value.end).valueOf() - moment(dateRange.value.start).valueOf()) / 1000 / 60 / 60 / 24}}

It's that easy!

valueOf() returns the millisecond of the moment in the Unix epoch which started 00:00:00 UTC on 1 January 1970. The consecutive divisions take us down to whole days (I've left them all there for clarity rather than just dividing by 86,400,000).

That's all, just thought it was time to give back...


Hi @Adam_Thomas, welcome to the fam :hugs:

Ah, the classic "divide by 1000, then 60, then another 60, and finally 24" method! Takes me back to the good ol' days of manual date arithmetic.

We do have access to moment "natively" which can shrink this down to:

moment(dateRange.value.end).diff(moment(dateRange.value.start), 'days')

Am wondering, has anyone found a leaner way of doing this? Not in a transformer or global function :smiley: