Hi @dan1… speak of the devil and in he walk.
So, what you and @julienallard1 observed is documented behavior. Please see:
(:to hours for date intervals is described right below there)
It might be helpful to scroll up from there, actually and read about the “date interval” type. When you subtract one date from another, this creates an object of “date interval” type (yes, it seems to be its own data type in Bubble)… as you can see here:
A date interval is a unit of time and, thus, is a rather handy thing to have in Bubble! It is described as follows in the docs:
Date interval type
This type represents a difference between two dates. It represents a precise number of milliseconds, rather than a calendar-friendly quantity such as “one day”. Adding and subtracting Date intervals always performs absolute math, not calendar-aware math. See the Date type above for more information on the difference between calendar-aware math and absolute math.
There is only one way to create a date interval: By subtracting one date from another. (Sort of like the ← range → constructor.)
Anyway, the descriptions of the date interval operators, point out the precision levels of each:
:format as days
Formats the difference as a number of days. We calculate this by dividing by 24 hours, then rounding to the nearest tenth (so 298944000 milliseconds becomes 3.5 days)
:format as hours
Formats the difference as a number of hours. We calculate this by dividing by one hour (i.e. 3,600,000 milliseconds) and rounding to the nearest tenth
:format as minutes
Formats the difference as a number of minutes. We divide through by 60,000 milliseconds and round to the nearest whole number
:format as seconds
Formats the difference as a number of seconds. We divide through by 1,000 milliseconds and round to the nearest whole number
So, that’s where all of that was coming from.
The precision of a date interval itself is milliseconds, as explained in the reference. So, yes, if you don’t like the :format rules for date intervals, you can just do the math yourself for complete control.
Don’t forget that operations like :format as return a string (text). Using such things is not the same as taking a date interval, dividing it by some number, and shoving that in custom state.
^^^ It would be worth testing: What data type is a date interval divided by a number? Does that yield a date interval? Or does it yield a number? NOTE: These things are different! A date interval is not a number representing milliseconds, it is in fact some amount of milliseconds. We could describe it as “time”. It is not, itself, a number.
(I haven’t tested this, but I’m pretty sure that date_interval / number yields a date_interval.)