How to find overlapping time periods?

Hi, I’m not sure how to show users in a repeating group that have overlapping ‘typical’ availability time periods. The word ‘typical’ is important, as it’s not specific date-times, it’s a time period of any day.

I’ve got User fields called ‘AvailFrom’ and ‘AvailTo’, which are numbers from 0 to 23 representing the hours of the day. I need to show in a repeating group the users that overlap with the current user’s availability period.

I’ve created some logic to calculate when they should be shown, but Bubble doesn’t let you enter these ANDs and ORs in the ‘Search for’ field. What I think I need is:

Show user in the repeating group when:

Their availability time period:     ---------------------
My availability time period:              --------

Their AvailFrom <= My AvailFrom
AND
Their AvailTo >= My AvailTo

OR

Them:           --------
Me:        ----------------------

Their AvailFrom >= My AvailFrom
AND
Their AvailTo <= My AvailTo

OR

Them:          --------------
Me:      ------------

Their AvailFrom <= My AvailTo
and
Their AvailTo >= My AvailTo

OR

Them:   -------------
Me:          --------------

Their AvailFrom <= My AvailFrom
AND
Their AvailTo >= My AvailFrom

Is this possible somehow in Bubble for a repeating group?

Thanks in advance!

Hi there, @andrew36… if I understand your post correctly, you would need to use an advanced filter that looks something like this.

If you haven’t used an advanced filter before, be aware that the filtering takes place on the client (browser) side. So, the search is going to return all of the relevant items to the browser (which would be all users in your database if there are no constraints on the search), and then the filter will be applied. As you can imagine, there could be a performance impact if there are a significant number of users in your database and you can’t constrain the search.

Hope this helps.

Best…
Mike

1 Like

That was super helpful, thanks! I didn’t know about ‘range’ and thought I needed to manually cater for all cases of overlap. It now works perfectly :grinning:

1 Like

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