Check whether Datetime is inside Daterange

Hello there,

I’d appreciate some help with this issue I’m having as I’ve spent quite a few hours trying to solve it without any luck.

I’m building a scheduler app and want to create a list of possible datetimes that a meeting could take place. For context, each person’s available time slots is stored in an ‘Availability’ data type which includes a Start and End date for each ‘Availability’. In the context of this app, playdate is a timeslot where two people’s availability overlaps.

What I’m trying to achieve is this. From the current user’s point of view, create and show a list of his available timeslots that overlaps with availability provided from any of this user’s friends. ‘Friends’ is a List of Users that is stored inside each user.

What I currently have (which doesn’t work) is this.

Step 1: Search for all availabilities by users who aren’t the current user.

Step 2: Compare each availability from step 1 with all availability entered by the current user. Check if the daterange of each availability by users who aren’t the current user overlaps with any of the dategranges entered by the current users.

As you can see from the red colour, it fails. The error I see is this:

The only way I got it to do anything is to check whether other users’ start date (per availability) ‘is in’ any of the current user’s availaiblities’ dateranges. However, ‘is in’ only works when they match exactly, rather than when they overlap. Therefore it’s not what I’m looking for.

Any and all help is very much appreciated

I have two constraints:

  1. Date Field is greater than or equal to range start
  2. Date Field is less than or equal to range end
1 Like

Thanks for the quick reply!

When I try that, it complains that the filtered value should be yes/no but right now it’s empty. I suspect it’s because I’m comparing each Availability’s single StarDateTime with a list of start times derived from the PlaydateDateRange:start, but I don’t quite get why that would be an issue.

Because you are not doing as I suggested.

In the Search for Availability, do not use :filtered operator as you are not supposed to use an Advanced filter. Instead in the Search for Availability add the constraints there.

2 constraints

Ah apologies for that. I was using Advanced filters in an attempt to get around this problem and didn’t clear them out.

I’ve changed it to the way you suggested (see picture below) but it’s still complaining about the same thing.

In an attempt to simplify it for myself, I created two repeating groups of availabilities, one containing the current user’s list (RepeatingGroupMyAvailabilities) and the other containing everybody else’s (RepeatingGroupNotMyAvailabilities). The final outcome I’m looking for is a list of everybody else’s availabilities whose dates overlap with the dateranges from any of the date ranges in the current user’s list.

Any and all help in solving this is very much appreciated

Your giving a list of dates when you reference repeating groups list…need a single date

What I need though is a list of availabilities whose dates overlap with those of another list of availabilities, a single date isn’t enough

Are you trying to create available timeslots for a booking app?

Yes indeed. Each user has a list of available timeslots and I’m trying to find the overlapping slots and suggest them to the users in order to book meetings where multiple parties are available at the same time.

You could check out my plugin, it might be sufficient for your use case.

Are you trying to allow one user to create booking slots that all other users are available or just getting available slots for each user separately?