how do I calculate the number of hours between a date range?
The formula I am using works when the date is the same (10/6/20 7 am to 10/6/20 7 pm) I get 12, however, once I switch it to another date the calculation is wrong (10/6/20 8 am to 10/7/20 8 pm) I get 0.
I searched the forum and haven’t been able to find a clear answer on this. Please help.
It would be helpful to see the Bubble expression you’re using. It should literally be as simple as subtracting one date from another and then formatting the result in hours.
Assuming your date range parameter name is “example_range”, it would go like this
example_range:end - example_range:start :format as hours
Be advised you used the term “range”, this is a reserved word. As there’s actually a Bubble datatype of “date range”, which I depicted. This would work however for any two arbitrary and unlinked date values.
Yeah, good point. To expound a bit for anyone coming across this post, a date range is a span of time bounded by two dates - the start and end (which @anon38627393 referenced). Once you have 2 dates, finding the difference is just subtraction, and it’ll be either zero (exactly the same date), positive, or negative.