Finding the longest gap between a list of dates

Hello,

I have a list of dates in my bubble app. I am looking to find the largest date range between 2 consecutive dates.

For example, if the list of dates were (jan4, jan7, jan 12, jan 14), it should return a value of 5 days because the largest gap between 2 consecutive dates is (jan12-jan7).

I appreciate any help, Thank You!

  • Sort the Dates: Use Bubble’s :sorted operator to ensure your list of dates is in ascending order.
  • Iterate and Calculate Differences: Loop through the sorted list and calculate the difference in days between each consecutive date.
  • Find the Maximum: Use Bubble’s :max operator to find the largest difference from the list of calculated differences.

How would this look like in bubble? How do you loop thru a list in bubble?

as @prosto.duda said, you need to loop through differences after sorting the date list. You can do that with scheduling a workflow.

if you’re on a free plan or just playing around, you can still do it with ‘do every 5 seconds’ but it’s unpractical. Here, check this example.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.