 # Doing math on dates

How come the number 2 suddenly becomes 2.5 in the next part of the expression?  Why doesn’t 2 + 1 = 3?

Anywho, I’m trying to build this expression:

(total number of log entries) / (number of days between today and oldest log entry) to get a number of logs per day metric.

A weirdness about dates is that if you’ve logged one time per day for three days, the math works out to 3/2 because today minus two days ago is two days, not three days.
5 on 30th
7 on 29th
9 on 28th
(total = 3) / (30-28 = 2) instead of (total = 3) / (3 days)
so I figured I’d just add 1 to the number of days calculation

Hey @blueback09,

Have you considered using the :change to operations to normalize your dates prior to manipulation?

1 Like

You mean the “:change X to” expressions where X is day/month/year/etc? Hmmm, yeah that might help to change all the hours and minutes to zero so that at least you’re working with full 24hr periods.

That’s correct. Since dates are really stored as ‘milliseconds since 1970’, you’ll find the Current date/time data is a number that’s formatted and sectioned by Bubble as per UTC. Normalizing to change a time section will help you get dates that you can easily manipulate with other dates, without non-zero time numbers. 1 Like