Difference between two dates/times


I’m relatively new to Bubble and I’ve tried searching the forum and guidance for a solution to what I’m trying to achieve but haven’t had much luck yet.

I have a form where people can log flights taken. On this form, there is a departure date/time field, an arrival date/time field and a ‘block time’ box. I’d like the ‘block time’ field to display the difference between the dep date/time and arrival dep/time, in hours and minutes only. I understand that all times are dates in reality so it’s probably more of a formatting issues. I’ve tried but I’m a bit stuck.

Anyone know the best way to do this?

I am using air date/time picker for the departure dates/times. Happy to provide access to my app if easier.


Hey Jason,

If you didn’t sort this out, this is how you do it:

First, you need to extract the hours. To do this, you use the time difference rounded down to the nearest hour. That requires the Floor function

Arrival time - departure time:floor

Next, you need to extract the minutes. To do this, you use the Modulo function. Modulo is the remainder after dividing one number by another

Arrival time - departure time:rounded to minutes modulo 60

So lets say a plane takes off at 2:02pm and arrives at 4:15pm. That is:

  1. 4-2 rounded down to nearest hour = 2

  2. 4.15pm - 2.02pm rounded to minutes = 133 minutes
    The modulo of 133 / 60 minutes = 13 mins.

=> So the difference is 2hrs 13mins.

And this is how it looks in my app:

1 Like

Hi Jeffrey - thanks for your help with this. I haven’t had a chance to look at my app recently but I’ll certainly try this out when I do. Appreciate it.